Skip to content
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

Add rule to disallow spreading array into object #476

Closed
ajafff opened this issue Dec 5, 2018 · 1 comment · Fixed by #750
Closed

Add rule to disallow spreading array into object #476

ajafff opened this issue Dec 5, 2018 · 1 comment · Fixed by #750

Comments

@ajafff
Copy link
Member

ajafff commented Dec 5, 2018

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.

Ref: palantir/tslint#4339

@ajafff
Copy link
Member Author

ajafff commented Feb 19, 2021

🎉 This issue has been resolved in version v0.24.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant