-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 4.0.0-beta
Search Terms: cannot be used to index type tuple partial generic template variadic
Code
type WithOneMore<T extends unknown[]> = [...T, ''];
type LengthPlusOne<T extends unknown[]> = WithOneMore<T>['length'];
type TestNowFour = LengthPlusOne<['a', 'b', 'c']>;
Expected behavior:
There should be no type checker errors. TestNowFour
is equal to the literal 4
.
Actual behavior:
The following error is emitted for WithOneMore<T>['length']
:
ts(2536): Type '"length"' cannot be used to index type '[...T, ""]'.
Interestingly, TestNowFour
is computed to be equal to the literal 4
regardless of the error.
Playground Link: Playground Link
Related Issues: Nothing particularly close. #5453 tracked the variadic kinds proposal and #39094 implemented them. I am keenly looking at what's coming out of the recursive conditional types mentioned in #40006 though...
ExE-Boss
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue