Skip to content

Conversation

@Andarist
Copy link
Contributor

@Andarist Andarist commented Dec 26, 2024

cc @sandersn

fixes #60590

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Dec 26, 2024
@Andarist Andarist changed the title Don't merge late bound assignment members with pre-existing symbols Stop reassigning .valueDeclaration to avoid replacing earlier declarations with late ones Dec 26, 2024
symbol.declarations.push(member);
}
if (symbolFlags & SymbolFlags.Value) {
if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) {
Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

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?

symbol.declarations.push(member);
}
if (symbolFlags & SymbolFlags.Value) {
if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) {
Copy link
Member

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.

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this after ignoring it for far too long. Would you mind merging from main before this goes in?

@github-project-automation github-project-automation bot moved this from Waiting on author to Needs merge in PR Backlog May 9, 2025
@Andarist
Copy link
Contributor Author

@sandersn done

@sandersn sandersn merged commit b86ab7d into microsoft:main May 15, 2025
32 checks passed
@github-project-automation github-project-automation bot moved this from Needs merge to Done in PR Backlog May 15, 2025
Copy link

@DingJun1028 DingJun1028 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

JSDoc property modifiers on computed properties

5 participants