-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[wontfix] fix(checker): Allow element access expressions in computed property names if argument is literal #62968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e813bb0
fix(checker): Allow element access expressions in computed property n…
kairosci 74055e7
Merge branch 'main' into fix/enum-computed-keys
kairosci 69bcbc4
Merge branch 'main' into fix/enum-computed-keys
kairosci 91424d8
fix(checker): Allow element access expressions in computed property n…
kairosci 5e9b706
Merge branch 'main' into fix/enum-computed-keys
kairosci d1fff11
Merge branch 'main' into fix/enum-computed-keys
kairosci 598f80f
Merge branch 'main' into fix/enum-computed-keys
kairosci a5d0446
Merge branch 'main' into fix/enum-computed-keys
kairosci 415baaa
fix: correct isLateBindableAST to pass entire ElementAccessExpression
kairosci edd40b2
Merge branch 'main' into fix/enum-computed-keys
kairosci 9c08657
Merge branch 'main' into fix/enum-computed-keys
kairosci File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
58 changes: 58 additions & 0 deletions
58
tests/baselines/reference/declarationEmitLateBoundAssignments.errors.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| declarationEmitLateBoundAssignments.ts(4,1): error TS7053: Element implicitly has an 'any' type because expression of type 'unique symbol' can't be used to index type 'typeof foo'. | ||
| Property '[_private]' does not exist on type 'typeof foo'. | ||
| declarationEmitLateBoundAssignments.ts(6,1): error TS7053: Element implicitly has an 'any' type because expression of type '"strMemName"' can't be used to index type 'typeof foo'. | ||
| Property 'strMemName' does not exist on type 'typeof foo'. | ||
| declarationEmitLateBoundAssignments.ts(8,1): error TS7053: Element implicitly has an 'any' type because expression of type '"dashed-str-mem"' can't be used to index type 'typeof foo'. | ||
| Property 'dashed-str-mem' does not exist on type 'typeof foo'. | ||
| declarationEmitLateBoundAssignments.ts(10,1): error TS7053: Element implicitly has an 'any' type because expression of type '42' can't be used to index type 'typeof foo'. | ||
| Property '42' does not exist on type 'typeof foo'. | ||
| declarationEmitLateBoundAssignments.ts(12,19): error TS7053: Element implicitly has an 'any' type because expression of type 'unique symbol' can't be used to index type 'typeof foo'. | ||
| Property '[_private]' does not exist on type 'typeof foo'. | ||
| declarationEmitLateBoundAssignments.ts(13,19): error TS7053: Element implicitly has an 'any' type because expression of type '"strMemName"' can't be used to index type 'typeof foo'. | ||
| Property 'strMemName' does not exist on type 'typeof foo'. | ||
| declarationEmitLateBoundAssignments.ts(14,19): error TS7053: Element implicitly has an 'any' type because expression of type '42' can't be used to index type 'typeof foo'. | ||
| Property '42' does not exist on type 'typeof foo'. | ||
| declarationEmitLateBoundAssignments.ts(15,19): error TS7053: Element implicitly has an 'any' type because expression of type '"dashed-str-mem"' can't be used to index type 'typeof foo'. | ||
| Property 'dashed-str-mem' does not exist on type 'typeof foo'. | ||
|
|
||
|
|
||
| ==== declarationEmitLateBoundAssignments.ts (8 errors) ==== | ||
| export function foo() {} | ||
| foo.bar = 12; | ||
| const _private = Symbol(); | ||
| foo[_private] = "ok"; | ||
| ~~~~~~~~~~~~~ | ||
| !!! error TS7053: Element implicitly has an 'any' type because expression of type 'unique symbol' can't be used to index type 'typeof foo'. | ||
| !!! error TS7053: Property '[_private]' does not exist on type 'typeof foo'. | ||
| const strMem = "strMemName"; | ||
| foo[strMem] = "ok"; | ||
| ~~~~~~~~~~~ | ||
| !!! error TS7053: Element implicitly has an 'any' type because expression of type '"strMemName"' can't be used to index type 'typeof foo'. | ||
| !!! error TS7053: Property 'strMemName' does not exist on type 'typeof foo'. | ||
| const dashStrMem = "dashed-str-mem"; | ||
| foo[dashStrMem] = "ok"; | ||
| ~~~~~~~~~~~~~~~ | ||
| !!! error TS7053: Element implicitly has an 'any' type because expression of type '"dashed-str-mem"' can't be used to index type 'typeof foo'. | ||
| !!! error TS7053: Property 'dashed-str-mem' does not exist on type 'typeof foo'. | ||
| const numMem = 42; | ||
| foo[numMem] = "ok"; | ||
| ~~~~~~~~~~~ | ||
| !!! error TS7053: Element implicitly has an 'any' type because expression of type '42' can't be used to index type 'typeof foo'. | ||
| !!! error TS7053: Property '42' does not exist on type 'typeof foo'. | ||
|
|
||
| const x: string = foo[_private]; | ||
| ~~~~~~~~~~~~~ | ||
| !!! error TS7053: Element implicitly has an 'any' type because expression of type 'unique symbol' can't be used to index type 'typeof foo'. | ||
| !!! error TS7053: Property '[_private]' does not exist on type 'typeof foo'. | ||
| const y: string = foo[strMem]; | ||
| ~~~~~~~~~~~ | ||
| !!! error TS7053: Element implicitly has an 'any' type because expression of type '"strMemName"' can't be used to index type 'typeof foo'. | ||
| !!! error TS7053: Property 'strMemName' does not exist on type 'typeof foo'. | ||
| const z: string = foo[numMem]; | ||
| ~~~~~~~~~~~ | ||
| !!! error TS7053: Element implicitly has an 'any' type because expression of type '42' can't be used to index type 'typeof foo'. | ||
| !!! error TS7053: Property '42' does not exist on type 'typeof foo'. | ||
| const a: string = foo[dashStrMem]; | ||
| ~~~~~~~~~~~~~~~ | ||
| !!! error TS7053: Element implicitly has an 'any' type because expression of type '"dashed-str-mem"' can't be used to index type 'typeof foo'. | ||
| !!! error TS7053: Property 'dashed-str-mem' does not exist on type 'typeof foo'. |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fall-through comment indentation changes in this file appear to be unrelated to the main fix for enum keys in type literals. While the new formatting is correct, these changes should ideally be in a separate commit or PR focused on code style/formatting cleanup.
If these changes are intentional cleanup, they should be mentioned in the PR description. If they were accidental changes from an auto-formatter, consider reverting them to keep this PR focused on the bug fix.