-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Instantiable tuple labels #55452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Instantiable tuple labels #55452
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
tests/baselines/reference/instantiableTupleLabels1.errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| instantiableTupleLabels1.ts(4,27): error TS5087: A labeled tuple element is declared as rest with a '...' before the name, rather than before the type. | ||
| instantiableTupleLabels1.ts(15,24): error TS2322: Type 'unknown' is not assignable to type 'string | number | bigint | boolean | null | undefined'. | ||
| instantiableTupleLabels1.ts(18,46): error TS2322: Type 'T1' is not assignable to type 'string | number | bigint | boolean | null | undefined'. | ||
| instantiableTupleLabels1.ts(18,71): error TS2322: Type 'T2' is not assignable to type 'string | number | bigint | boolean | null | undefined'. | ||
|
|
||
|
|
||
| ==== instantiableTupleLabels1.ts (4 errors) ==== | ||
| type T1 = [`wow`: boolean]; | ||
| type T2 = [number, `wow`: boolean]; | ||
| type T3 = [number, ...`wow`: boolean[]]; | ||
| type T4 = [number, `wow`: ...boolean[]]; // error | ||
| ~~~~~~~~~~~~ | ||
| !!! error TS5087: A labeled tuple element is declared as rest with a '...' before the name, rather than before the type. | ||
|
|
||
| type Prefix = 'pre'; | ||
|
|
||
| type T5 = [`${Prefix}wow`: boolean]; | ||
| type T6 = [number, `${Prefix}wow`: boolean]; | ||
| type T7 = [number, ...`${Prefix}wow`: boolean[]]; | ||
|
|
||
| type T8 = [number, `${never}wontfly`: boolean]; // no label displayed | ||
| type T9 = [number, `${any}wontfly`: boolean]; // no label displayed | ||
| type T11 = [number, `${"a" | "b"}wontfly`: boolean]; // no label displayed | ||
| type T12 = [number, `${unknown}wontfly`: boolean]; // error | ||
| ~~~~~~~ | ||
| !!! error TS2322: Type 'unknown' is not assignable to type 'string | number | bigint | boolean | null | undefined'. | ||
|
|
||
| type MakeTuple1<T1 extends string, T2 extends string> = [number, `second-${T1}`: string, ...`rest-${T2}`: boolean[]]; | ||
| type MakeTuple2<T1, T2> = [number, `second-${T1}`: string, ...`rest-${T2}`: boolean[]]; // error | ||
| ~~ | ||
| !!! error TS2322: Type 'T1' is not assignable to type 'string | number | bigint | boolean | null | undefined'. | ||
| !!! related TS2208 instantiableTupleLabels1.ts:18:17: This type parameter might need an `extends string | number | bigint | boolean | null | undefined` constraint. | ||
| ~~ | ||
| !!! error TS2322: Type 'T2' is not assignable to type 'string | number | bigint | boolean | null | undefined'. | ||
| !!! related TS2208 instantiableTupleLabels1.ts:18:21: This type parameter might need an `extends string | number | bigint | boolean | null | undefined` constraint. | ||
|
|
||
| type T13 = MakeTuple1<"awesome", "tail">; | ||
| type T14 = MakeTuple1<any, "tail">; | ||
| type T15 = MakeTuple1<"a" | "b", "tail">; | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MariaSolOs what kind of inlay hint interactivity is expected out of a parameter name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expected behaviour is to be able to click on an argument of a function call and have that be a "go to definition" to the respective parameter in the function signature.