Allow element access on enum as computed property name in type literal#63526
Closed
driphtyio wants to merge 2 commits into
Closed
Allow element access on enum as computed property name in type literal#63526driphtyio wants to merge 2 commits into
driphtyio wants to merge 2 commits into
Conversation
Contributor
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.
Member
|
This doesn't meet the 6.0 patch bar #62963 (comment) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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