8000 TypeScript5.0以降でconst Type Parametersが追加されたので説明を追加しませんか? · Issue #667 · yytypescript/book · GitHub
[go: up one dir, main page]

Skip to content
TypeScript5.0以降でconst Type Parametersが追加されたので説明を追加しませんか? #667
@k35o

Description

@k35o
< 75FB div class="ActivityHeader-module__edits--LwHTE IssueBodyHeader-module__editsSection--dH32c">

型変数の修飾子として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

No one assigned

    Labels

    chapter:読んで学ぶ「読んで学ぶ」リファレンス系のコンテンツです。stage1:話し合い中結論を出すために話し合いをしている最中です。まだ着手・プルリクエストの作成はしないでください。type:新verへの追従時間経過でバージョンが古くなってしまった内容を改善する

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0