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 call for a2 has the following error (b3, c3 also have the same error type, adjusted for their parameters):
ts(2345)
Argument of type '["home", "user", string, string]' is not assignable to parameter of type 'readonly ["home", "user", string, "doc.pdf"]'.
Type at position 3 in source is not compatible with type at position 3 in target.
Type 'string' is not assignable to type '"doc.pdf"'.
The call for b2 has the following error (c2, d2, d3 also have the same error type, adjusted for their parameters):
ts(2322)
Type 'string' is not assignable to type '"folder"'.
🙂 Expected behavior
Don't generate false-positive errors. Also, it's odd that there is no apparent pattern to when one of the errors is shown.
Workaround
To silence these errors, as const can be used, but again, it's not really obvious where or how many times.
This partial code sample generates no errors:
Yeah, there's an issue here relating to how we compute contextual types for array literal elements in positions following a spread element. We wrongly assume that the position of the element in the array literal corresponds to the index of the element in the resulting tuple type--which isn't always the case when there's a preceding spread element.
Bug Report
🕗 Version & Regression Information
It's not a regression, the same behaviour can be observed on TS 4 and 5. (for TS 4, using ts-toolbelt's Narrow function gives equivalent results)
💻 Code
🙁 Actual behavior
All return types are correct, e.g.:
The call for a2 has the following error (b3, c3 also have the same error type, adjusted for their parameters):
The call for b2 has the following error (c2, d2, d3 also have the same error type, adjusted for their parameters):
🙂 Expected behavior
Don't generate false-positive errors. Also, it's odd that there is no apparent pattern to when one of the errors is shown.
Workaround
To silence these errors,
as const
can be used, but again, it's not really obvious where or how many times.This partial code sample generates no errors:
This partial code sample still has false-positive errors:
The text was updated successfully, but these errors were encountered: