Skip to content
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(61258): Renaming namespace with const enum doesn't update enum references #61263

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

a-tarasyuk
Copy link
Contributor

Fixes #61258

Comment on lines 10 to 14
module foo {
>foo : typeof foo
> : ^^^^^^^^^^

const enum E { X }
Copy link
Member

Choose a reason for hiding this comment

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

I am suspicious of this; this implies that we are giving foo a type when it doesn't actually exist, no?

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’m surprised that a helper from services changes types :)

export function getMeaningFromDeclaration(node: Node): SemanticMeaning {

This helper is used by findAll to obtain semantic meaning for the search

const searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : SemanticMeaning.All;

const declarationMeaning = getMeaningFromDeclaration(declaration);

else if (getModuleInstanceState(node as ModuleDeclaration) === ModuleInstanceState.Instantiated) {
return SemanticMeaning.Namespace | SemanticMeaning.Value;
}

Since the module instance state for constant enums uses the separate value ConstEnumOnly instead of Instantiated, the Value meaning is not allowed in the search, and findAll skips it

if (!hasMatchingMeaning(referenceLocation, state)) return;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

Renaming namespace with const enum doesn't update enum references
2 participants