-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Destructuring array into an object is assignable to an array type #34780
Comments
See #9726 - TS would need a way to know that the array methods don't end up on |
@RyanCavanaugh is this really a design limitation due to lack of enumerable properties? I believe in a very similar case for objects (not arrays) the type is correctly inferred:
Could we have similar feature for arrays? |
yeah i found that too doing a |
@sebapawlak TS knows which members of a class are enumerable and which aren't, but we don't have any declaration form for annotated the value-declared type of |
TypeScript Version: 3.8.0-dev.20191026
Search Terms:
Code
Expected behavior: Typescript errors about type mismatch.
Actual behavior: Typescript does neither warn nor error about this and
foo
is no longer an array.Playground Link: https://www.typescriptlang.org/play/?ts=3.8.0-dev.20191026&ssl=1&ssc=18&pln=1&pc=8#code/DYUwLgBARghgThAvBA2gRgDQQExYMwC6AUEaJAGYD2lAXBDAHYCeKBSEA3hAHS+wIBfEgGNKDAM6VQ3YJQDmACgCCcODCbcAluJVqmCqpQCURiAHozEcjGDiQQA
Related Issues: #14768
The text was updated successfully, but these errors were encountered: