Commit 6bb6151
committed
Fix #25083: Allow bracket notation for enum keys in computed properties
This commit fixes an issue where using bracket notation to access enum
members (e.g., Type['key']) was not accepted in computed property names
of type literals, even though dot notation (e.g., Type.key) worked fine.
The problem was in the isLateBindableAST function in checker.ts, which
only accepted EntityNameExpression. Element access expressions like
Type['key'] were rejected even though they resolve to the same literal
type as their dot notation equivalents.
Changes:
- Modified isLateBindableAST to accept ElementAccessExpression when the
base object is an EntityNameExpression
- This enables bracket notation for accessing enum members with
non-identifier names (e.g., '3x14' or names starting with digits)
- Added comprehensive test case covering various scenarios including
identifier and non-identifier enum keys with bracket notation
Fixes #25083
Signed-off-by: Rodrigo Sanchez <Rodrigo@sanchezdev.com>1 parent f5ccf43 commit 6bb6151
File tree
2 files changed
+54036
-53955
lines changed- src/compiler
- tests/cases/compiler
2 files changed
+54036
-53955
lines changed
0 commit comments