-
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
Stop reassigning .valueDeclaration
to avoid replacing earlier declarations with late ones
#60857
base: main
Are you sure you want to change the base?
Stop reassigning .valueDeclaration
to avoid replacing earlier declarations with late ones
#60857
Conversation
.valueDeclaration
to avoid replacing earlier declarations with late ones
@@ -13197,10 +13197,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { | |||
else if (!member.symbol.isReplaceableByMethod) { | |||
symbol.declarations.push(member); | |||
} | |||
if (symbolFlags & SymbolFlags.Value) { | |||
if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { |
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.
Was the original logic trying to preserve the somewhat-sketchy logic in the binder around which type of declaration "wins" out?
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 sure looks like it, but there's a separate utility function for that now: setValueDeclaration
, which is more complicated*. Specifically, the kind
check is only for namespaces there, which wouldn't apply to this
property assignments.
I think the better fix to try is
if (symbolFlags & SymbolFlags.Value) {
setValueDeclaration(symbol, member)
}
In other words, what the binder does in addDeclarationToSymbol
.
*It also has a 3rd case for function property assignments in .d.ts files.
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.
I pushed out this change. Could you take another look?
@@ -13197,10 +13197,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { | |||
else if (!member.symbol.isReplaceableByMethod) { | |||
symbol.declarations.push(member); | |||
} | |||
if (symbolFlags & SymbolFlags.Value) { | |||
if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { |
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 sure looks like it, but there's a separate utility function for that now: setValueDeclaration
, which is more complicated*. Specifically, the kind
check is only for namespaces there, which wouldn't apply to this
property assignments.
I think the better fix to try is
if (symbolFlags & SymbolFlags.Value) {
setValueDeclaration(symbol, member)
}
In other words, what the binder does in addDeclarationToSymbol
.
*It also has a 3rd case for function property assignments in .d.ts files.
cc @sandersn
fixes #60590