-
Notifications
You must be signed in to change notification settings - Fork 12.8k
When the initial element of the tuple is a rest element, it is not possible to correctly infer the type of the initial element. #56883
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
Comments
This is behaving as designed according to #41544 and therefore not considered a bug:
Perhaps you'd like to rephrase this as a feature request? |
From my understanding, your initial type Here is a quick example: Let me know if I missed something |
You missed that it couldn't be |
This comment was marked as outdated.
This comment was marked as outdated.
That's out of date with whatever changes were made in 5.0.8 that fixed #49138. See the following examples: type T1 = [...string[], number, boolean]
const arr1: T1 = [2, true];
const arr2: T1 = ["", 2, true];
const arr3: T1 = [true];
declare const arr: T1;
const head = arr[0]
// Actual: string | number | boolean
// Expected: string | number |
I continue to be confused by these comments (especially when they get deleted out of the middle of a discussion). It is by design that |
π Search Terms
initial element of the tuple is a rest element
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?ts=5.3.2#code/C4TwDgpgBAKgjFAvFA2gOgwZ2AJwJYB2A5igLoA0UBArgLYBGEOl9A9qwDYQCGBpAsACghAEwgBjDtxzRxrAtijScALlhwhQuQuBQAFjxFIlOHCgAMAwVBsB6W1AB6AfiE2o9qAFEAHpHHAECJq2PjEUAA+VHSMOEA
π» Code
π Actual behavior
When the initial element of the tuple is a rest element, it is not possible to correctly infer the type of the initial element.
π Expected behavior
Infer the correct type.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: