-
Notifications
You must be signed in to change notification settings - Fork 13k
Fix #17023 #17180
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
Fix #17023 #17180
Conversation
src/compiler/checker.ts
Outdated
function getBindingElementNameText(element: BindingElement): string | undefined { | ||
if (element.parent.kind === SyntaxKind.ObjectBindingPattern) { | ||
const name = element.propertyName || element.name; | ||
if (isComputedNonLiteralName(name as PropertyName)) return undefined; |
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.
Consider moving this down to the analogous case
clause to make it clearer that it's safe to assert name.expression
as LiteralExpression
Can you make sure that performance doesn't get worse with this change? This would only apply for code bases that use binding patterns, of course, so I guess our own compiler would be a good test case. Maybe? |
src/compiler/checker.ts
Outdated
if (node.kind === SyntaxKind.BindingElement) { | ||
const key = node.parent.parent.kind === SyntaxKind.BindingElement ? getFlowCacheKey(node.parent.parent) : isApparentTypePosition(node.parent.parent) ? "@<initializer>" : "<initializer>"; | ||
const text = getBindingElementNameText(node as BindingElement); | ||
return key && text && key + "." + text; |
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.
it sounds like from our discussion at lunch that you came up with a better way to make a key.
@sandersn I've done my work to find a better cache key (now it follows the same trail
Master, de9a67f:
Together:
So... no difference. |
Fixes #17023 - binding patterns correctly have their initial type bound to the narrowed type of the narrowed property indicated by the binding pattern. Previously, we were not getting their flow type when looking for their initial type (and the flow logic wasn't setup to look for references equivalent to a nested binding element).