Skip to content

Qualify enum member names when referencing in value position #62034

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

RyanCavanaugh
Copy link
Member

Fixes #61944

This doesn't have any observable effects (AFAICT) on the forms like

enum Foo {
  bar,
  baz = bar
}

because we never try to declaration emit those in symbolic form - for a literal value of bar, they're both = 0; for a computed value, you don't see the initializer on baz at all

@Copilot Copilot AI review requested due to automatic review settings July 10, 2025 07:01
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Jul 10, 2025
@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Jul 10, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes issue #61944 by ensuring that enum member names are qualified when referenced in value positions during declaration emission. The change prevents TypeScript from emitting invalid unqualified enum member references in declaration files.

Key changes:

  • Modified the symbol qualification logic in the type checker to force qualification for enum members in value contexts
  • Added a test case to verify the fix works correctly for enum members referenced within namespaces

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/compiler/checker.ts Updated symbol qualification logic to force qualification for enum members in value contexts
tests/cases/compiler/invalidUnqualifiedEnum.ts Added test case with enum and namespace scenario that would previously emit invalid code
tests/baselines/reference/invalidUnqualifiedEnum.types Test baseline for type information output
tests/baselines/reference/invalidUnqualifiedEnum.symbols Test baseline for symbol resolution output
tests/baselines/reference/invalidUnqualifiedEnum.js Test baseline for compiled JavaScript and declaration file output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

Incorrect type declarations for a constant inside a namespace merged with an enum
2 participants