Allow element access on enum as computed property name in type literal#63526
Allow element access on enum as computed property name in type literal#63526driphtyio wants to merge 2 commits into
Conversation
|
@driphtyio please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
1 similar comment
|
@driphtyio please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates documentation wording and broadens the TypeScript checker’s definition of “late-bindable” AST nodes to include a specific element-access pattern.
Changes:
- Clarify
Set.sizeJSDoc wording ines2015.collection.d.ts. - Extend
isLateBindableASTto treatEntity["prop"](string-literal element access off an entity name) as late-bindable.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/lib/es2015.collection.d.ts | Small JSDoc wording tweak for Set.size. |
| src/compiler/checker.ts | Expands late-bindable detection logic for additional AST form. |
Comments suppressed due to low confidence (1)
src/compiler/checker.ts:1
- The mixed
||/&&expression relies on operator precedence, which is easy to misread and error-prone during future edits (especially with the line break). Add explicit parentheses (or assign the element-access sub-check to a well-named boolean) to make the intended grouping unambiguous.
Fixes #25083
Problem
Enum keys with non-identifier names (e.g., '3x14') cannot be used as computed property keys in type literals because bracket access (Type['3x14']) produces an ElementAccessExpression node that isLateBindableAST() does not recognize.
Reproduction
Fix
3-line addition to isLateBindableAST() in src/compiler/checker.ts: when the expression is an ElementAccessExpression with a string literal argument on an entity name, treat it as late-bindable.
Properties