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
declareletarr: [string,number];arr.splice(1);// mutates arr, making it only [string]letarr2=arr;// incorrectly inferred as [string, number]letarr3=arras[string];// incorrect conversion error
π Actual behavior
See the comments in code above. What the TypeScript compiler infers is different from the actual runtime behavior.
It's worth noting that the return value of the call to splice() is correctly inferred as (string | number)[].
π Expected behavior
Either calling arr.splice(1) should be an error (due to calling splice on a tuple), or the type of arr should be different after calling arr.splice(1).
The text was updated successfully, but these errors were encountered:
Bug Report
π Search Terms
tuple splice
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
See the comments in code above. What the TypeScript compiler infers is different from the actual runtime behavior.
It's worth noting that the return value of the call to
splice()
is correctly inferred as(string | number)[]
.π Expected behavior
Either calling
arr.splice(1)
should be an error (due to calling splice on a tuple), or the type ofarr
should be different after callingarr.splice(1)
.The text was updated successfully, but these errors were encountered: