Skip to content

Comments

Fixed a crash related to computed enum member keys#63182

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

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
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
Member

Can you explain the fix?

@Andarist
Copy link
Contributor Author

@jakebailey sure, edited the PR summary

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

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

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