-
Notifications
You must be signed in to change notification settings - Fork 110
Open
Labels
chapter:読んで学ぶ「読んで学ぶ」リファレンス系のコンテンツです。「読んで学ぶ」リファレンス系のコンテンツです。stage1:話し合い中結論を出すために話し合いをしている最中です。まだ着手・プルリクエストの作成はしないでください。結論を出すために話し合いをしている最中です。まだ着手・プルリクエストの作成はしないでください。type:新verへの追従時間経過でバージョンが古くなってしまった内容を改善する時間経過でバージョンが古くなってしまった内容を改善する
Description
opened on Mar 20, 2023
<
75FB
div class="ActivityHeader-module__edits--LwHTE IssueBodyHeader-module__editsSection--dH32c">
Issue body actions
型変数の修飾子としてconst
が使えるようになったので、その説明を追加しませんか?
const
を型変数の前に付け加えることで、推論がより具体的な型になる機能です。
declare function fnNotUseConst<T extends readonly string[]>(args: T): T;
declare function fnUseConst<const T extends readonly string[]>(args: T): T;
// Return value is string[]
fnNotUseConst(["a", "b" ,"c"]);
// Return value is readonly ["a", "b", "c"]
fnUseConst(["a", "b" ,"c"]);
関連するページ
https://typescriptbook.jp/reference/generics/type-variables
関連するドキュメント
https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#const-type-parameters
microsoft/TypeScript#51865
Metadata
Metadata
Assignees
Labels
chapter:読んで学ぶ「読んで学ぶ」リファレンス系のコンテンツです。「読んで学ぶ」リファレンス系のコンテンツです。stage1:話し合い中結論を出すために話し合いをしている最中です。まだ着手・プルリクエストの作成はしないでください。結論を出すために話し合いをしている最中です。まだ着手・プルリクエストの作成はしないでください。type:新verへの追従時間経過でバージョンが古くなってしまった内容を改善する時間経過でバージョンが古くなってしまった内容を改善する