型変数の修飾子として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
型変数の修飾子として
constが使えるようになったので、その説明を追加しませんか?constを型変数の前に付け加えることで、推論がより具体的な型になる機能です。関連するページ
https://typescriptbook.jp/reference/generics/type-variables
関連するドキュメント
https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#const-type-parameters
microsoft/TypeScript#51865