-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Fixed declaration emit for expando properties on function declarations declared using element access expressions #55183
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
Merged
weswigham
merged 8 commits into
microsoft:main
from
Andarist:fix/element-access-late-bound-assignments-on-fn-decl
Sep 13, 2023
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7c6b7d9
Fixed declaration emit for expando properties on function declaration…
Andarist a07458b
Merge remote-tracking branch 'origin/main' into fix/element-access-la…
Andarist bc9c536
Rename the introduced helper
Andarist 31d9c72
Merge remote-tracking branch 'origin/main' into fix/element-access-la…
Andarist cbb47d3
add more tests
Andarist 5a368f0
preserve numeric input key style of computed expando properties
Andarist f0168e4
Merge remote-tracking branch 'origin/main' into fix/element-access-la…
Andarist 9069e38
Merge remote-tracking branch 'origin/main' into fix/element-access-la…
Andarist 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
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
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
186 changes: 186 additions & 0 deletions
186
tests/baselines/reference/declarationEmitLateBoundAssignments2.js
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,186 @@ | ||
//// [tests/cases/compiler/declarationEmitLateBoundAssignments2.ts] //// | ||
|
||
//// [declarationEmitLateBoundAssignments2.ts] | ||
// https://github.com/microsoft/TypeScript/issues/54811 | ||
|
||
const c = "C" | ||
const num = 1 | ||
const numStr = "10" | ||
const withWhitespace = "foo bar" | ||
const emoji = "🤷♂️" | ||
|
||
export function decl() {} | ||
decl["B"] = 'foo' | ||
|
||
export function decl2() {} | ||
decl2[c] = 0 | ||
|
||
export function decl3() {} | ||
decl3[77] = 0 | ||
|
||
export function decl4() {} | ||
decl4[num] = 0 | ||
|
||
export function decl5() {} | ||
decl5["101"] = 0 | ||
|
||
export function decl6() {} | ||
decl6[numStr] = 0 | ||
|
||
export function decl7() {} | ||
decl7["qwe rty"] = 0 | ||
|
||
export function decl8() {} | ||
decl8[withWhitespace] = 0 | ||
|
||
export function decl9() {} | ||
decl9["🤪"] = 0 | ||
|
||
export function decl10() {} | ||
decl10[emoji] = 0 | ||
|
||
export const arrow = () => {} | ||
arrow["B"] = 'bar' | ||
|
||
export const arrow2 = () => {} | ||
arrow2[c] = 100 | ||
|
||
export const arrow3 = () => {} | ||
arrow3[77] = 0 | ||
|
||
export const arrow4 = () => {} | ||
arrow4[num] = 0 | ||
|
||
export const arrow5 = () => {} | ||
arrow5["101"] = 0 | ||
|
||
export const arrow6 = () => {} | ||
arrow6[numStr] = 0 | ||
|
||
export const arrow7 = () => {} | ||
arrow7["qwe rty"] = 0 | ||
|
||
export const arrow8 = () => {} | ||
arrow8[withWhitespace] = 0 | ||
|
||
export const arrow9 = () => {} | ||
arrow9["🤪"] = 0 | ||
|
||
export const arrow10 = () => {} | ||
arrow10[emoji] = 0 | ||
|
||
|
||
//// [declarationEmitLateBoundAssignments2.js] | ||
// https://github.com/microsoft/TypeScript/issues/54811 | ||
const c = "C"; | ||
const num = 1; | ||
const numStr = "10"; | ||
const withWhitespace = "foo bar"; | ||
const emoji = "🤷♂️"; | ||
export function decl() { } | ||
decl["B"] = 'foo'; | ||
export function decl2() { } | ||
decl2[c] = 0; | ||
export function decl3() { } | ||
decl3[77] = 0; | ||
export function decl4() { } | ||
decl4[num] = 0; | ||
export function decl5() { } | ||
decl5["101"] = 0; | ||
export function decl6() { } | ||
decl6[numStr] = 0; | ||
export function decl7() { } | ||
decl7["qwe rty"] = 0; | ||
export function decl8() { } | ||
decl8[withWhitespace] = 0; | ||
export function decl9() { } | ||
decl9["🤪"] = 0; | ||
export function decl10() { } | ||
decl10[emoji] = 0; | ||
export const arrow = () => { }; | ||
arrow["B"] = 'bar'; | ||
export const arrow2 = () => { }; | ||
arrow2[c] = 100; | ||
export const arrow3 = () => { }; | ||
arrow3[77] = 0; | ||
export const arrow4 = () => { }; | ||
arrow4[num] = 0; | ||
export const arrow5 = () => { }; | ||
arrow5["101"] = 0; | ||
export const arrow6 = () => { }; | ||
arrow6[numStr] = 0; | ||
export const arrow7 = () => { }; | ||
arrow7["qwe rty"] = 0; | ||
export const arrow8 = () => { }; | ||
arrow8[withWhitespace] = 0; | ||
export const arrow9 = () => { }; | ||
arrow9["🤪"] = 0; | ||
export const arrow10 = () => { }; | ||
arrow10[emoji] = 0; | ||
|
||
|
||
//// [declarationEmitLateBoundAssignments2.d.ts] | ||
export declare function decl(): void; | ||
export declare namespace decl { | ||
var B: string; | ||
} | ||
export declare function decl2(): void; | ||
export declare namespace decl2 { | ||
var C: number; | ||
} | ||
export declare function decl3(): void; | ||
export declare namespace decl3 { } | ||
export declare function decl4(): void; | ||
export declare namespace decl4 { } | ||
export declare function decl5(): void; | ||
export declare namespace decl5 { } | ||
export declare function decl6(): void; | ||
export declare namespace decl6 { } | ||
export declare function decl7(): void; | ||
export declare namespace decl7 { } | ||
export declare function decl8(): void; | ||
export declare namespace decl8 { } | ||
export declare function decl9(): void; | ||
export declare namespace decl9 { } | ||
export declare function decl10(): void; | ||
export declare namespace decl10 { } | ||
export declare const arrow: { | ||
(): void; | ||
B: string; | ||
}; | ||
export declare const arrow2: { | ||
(): void; | ||
C: number; | ||
}; | ||
export declare const arrow3: { | ||
(): void; | ||
77: number; | ||
}; | ||
export declare const arrow4: { | ||
(): void; | ||
1: number; | ||
}; | ||
export declare const arrow5: { | ||
(): void; | ||
"101": number; | ||
}; | ||
export declare const arrow6: { | ||
(): void; | ||
"10": number; | ||
}; | ||
export declare const arrow7: { | ||
(): void; | ||
"qwe rty": number; | ||
}; | ||
export declare const arrow8: { | ||
(): void; | ||
"foo bar": number; | ||
}; | ||
export declare const arrow9: { | ||
(): void; | ||
"\uD83E\uDD2A": number; | ||
}; | ||
export declare const arrow10: { | ||
(): void; | ||
"\uD83E\uDD37\u200D\u2642\uFE0F": number; | ||
}; |
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.
those don't work because function declarations are emitted as namespaces and non-identifiers can't be exported from namespaces, see: #55190
I could make an effort to avoid those empty namespaces. The issue itself stands though. I think it's a slight problem that function declarations and function expressions have such a subtle and silent (!) difference in their capabilities to emit expando members