You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The text was updated successfully, but these errors were encountered:
avaly
changed the title
Infering rest of array in a conditional results in unknown[]
Inferring rest of array in a conditional results in unknown[]Aug 2, 2021
Not only the rest of the array is misinferred, but any element as well:
typeFoobar<Textendsstring[]>=Textends[infer F, ...infer R]
? [`${F}`, `${R[0]}`]
: never// Type 'F' is not assignable to type 'string | number | bigint | boolean | null | undefined'.// Type 'R[0]' is not assignable to type 'string | number | bigint | boolean | null | undefined'.// Type 'unknown' is not assignable to type 'string | number | bigint | boolean | null | undefined'.
Bug Report
π Search Terms
infer conditional array rest unknown
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
Using code from the #40336 description restricted to strings only:
π Actual behavior
R
is inferred as beingunknown[]
.π Expected behavior
R
should be inferred as beingstring[]
.The text was updated successfully, but these errors were encountered: