-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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 implicit any errors for destructuring computed names which aren't late bound and have no corresponding index #23489
Conversation
…late bound and have no corresponding index
src/compiler/checker.ts
Outdated
if (isTypeAssignableToKind(exprType, TypeFlags.NumberLike)) { | ||
indexerType = getIndexTypeOfType(parentType, IndexKind.Number); | ||
} | ||
else if (isTypeAssignableToKind(exprType, TypeFlags.StringLike)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string is valid for number indexing as well.. so symbols aside..
indexrType = (isTypeAssignableToKind(exprType, TypeFlags.NumberLike) && getIndexTypeOfType(parentType, IndexKind.Number) || getIndexTypeOfType(parentType, IndexKind.String)
e78530c
to
d965c33
Compare
src/compiler/checker.ts
Outdated
if (isTypeAssignableToKind(exprType, TypeFlags.NumberLike)) { | ||
indexerType = getIndexTypeOfType(parentType, IndexKind.Number) || getIndexTypeOfType(parentType, IndexKind.String); | ||
} | ||
else if (isTypeAssignableToKind(exprType, TypeFlags.StringLike)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const named = Symbol("");
let { [named]: prop } = strIndexed;
void prop;``
today that is string
... we probably wanna keep it this way until we have a symbol indexer.
@mhegazy updated. Destructuring now has the same buggy behavior as indexing 😿 |
We need to update it to handle symbols like we do in regular indexing. |
@mhegazy Does this look like the correct errors to issue for symbol destructuring (and should they be noImplicitAny)? |
Fixes #23334