Skip to content

Fixed a crash related to computed enum member keys#63182

Closed
Andarist wants to merge 1 commit intomicrosoft:mainfrom
Andarist:fix/crash-computed-enum-member-key
Closed

Fixed a crash related to computed enum member keys#63182
Andarist wants to merge 1 commit intomicrosoft:mainfrom
Andarist:fix/crash-computed-enum-member-key

Conversation

@Andarist
Copy link
Copy Markdown
Contributor

@Andarist Andarist commented Feb 22, 2026

Enum members are in the scope of the enum declaration as this is allowed:

declare const enum E {
  foo = "foo",
  foobar = foo + "bar",
}

That allows the identifier in the computed key to attempt resolving in the same way. However, that leads to a cycle with enums:
getDeclaredTypeOfEnum(E) -> hasBindableName -> isLateBindableName -> checkComputedPropertyName -> checkExpression -> checkIdentifier -> getNarrowedTypeOfSymbol -> getTypeOfSymbol -> getTypeOfEnumMember(E.foo) -> getTypeOfEnumMember -> getDeclaredTypeOfEnumMember -> getDeclaredTypeOfEnum(E)

Given enums can't really have computed keys (as shown in the added tests given the reported "TS1164: Computed property names are not allowed in enums." diagnostic), the simplest fix is to just check if the member !hasDynamicName(member) instead of hasBindableName(member) (the latter calls || isLateBindableName(member))

fixes #63173

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Feb 22, 2026
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Feb 22, 2026
@jakebailey
Copy link
Copy Markdown
Member

Can you explain the fix?

@Andarist
Copy link
Copy Markdown
Contributor Author

@jakebailey sure, edited the PR summary

@typescript-bot typescript-bot added For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Feb 24, 2026
@typescript-bot
Copy link
Copy Markdown
Collaborator

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate

@github-project-automation github-project-automation bot moved this from Not started to Done in PR Backlog Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Crash: Maximum call stack size exceeded when declare const enum has a computed property named [object] followed by an object member

3 participants