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
Currently TypeScript allows spreading arrays into objects. Technically that's correct. But it keeps all prototype methods while computing the resulting type of the spread. This makes it compatible with the real Array type and can cause runtime errors.
({...[]}).reverse();// runtime error
The same problem exists for everything else that's technically a class, but is declared as interface which has methods.
In practice this most often happens with arrays as the tokens are very similar.
Ref: microsoft/TypeScript#28801
If the TypeScript team decides to fix this in the compiler there's nothing to do here.
Currently TypeScript allows spreading arrays into objects. Technically that's correct. But it keeps all prototype methods while computing the resulting type of the spread. This makes it compatible with the real
Array
type and can cause runtime errors.The same problem exists for everything else that's technically a class, but is declared as interface which has methods.
In practice this most often happens with arrays as the tokens are very similar.
Ref: microsoft/TypeScript#28801
If the TypeScript team decides to fix this in the compiler there's nothing to do here.
Ref: palantir/tslint#4339
The text was updated successfully, but these errors were encountered: