-
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
Fixed declaration emit for expando properties on function declarations declared using element access expressions #55183
Conversation
…s declared using element access expressions
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.
Looks good: I had one question, one name change, and one test case request.
const c = "C" | ||
|
||
export function decl () {} | ||
decl["B"] = 'foo' |
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.
what does the BinaryExpression case look like? If there's not a test for it here or somewhere else, please add one.
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.
It's the decl2
case. This is the baseline diff without the isBinaryExpression
check:
baseline diff
diff --git a/tests/baselines/reference/declarationEmitLateBoundAssignments.js b/tests/baselines/reference/declarationEmitLateBoundAssignments.js
index b76db45754..763511ec0d 100644
--- a/tests/baselines/reference/declarationEmitLateBoundAssignments.js
+++ b/tests/baselines/reference/declarationEmitLateBoundAssignments.js
@@ -38,5 +38,4 @@ const a = foo[dashStrMem];
export declare function foo(): void;
export declare namespace foo {
var bar: number;
- var strMemName: string;
}
diff --git a/tests/baselines/reference/declarationEmitLateBoundAssignments2.js b/tests/baselines/reference/declarationEmitLateBoundAssignments2.js
index 4ec90c2606..b2d3efc2a8 100644
--- a/tests/baselines/reference/declarationEmitLateBoundAssignments2.js
+++ b/tests/baselines/reference/declarationEmitLateBoundAssignments2.js
@@ -37,9 +37,6 @@ export declare namespace decl {
var B: string;
}
export declare function decl2(): void;
-export declare namespace decl2 {
- var C: number;
-}
export declare const arrow: {
(): void;
B: string;
…te-bound-assignments-on-fn-decl
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.
Can we just add some test cases for expando element access properties with non-identifier names (numbers, strings with spaces, unique symbols)? This looks good, I just wanna make sure we don't try and emit { a b: string }
or something equally silly.
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 { } |
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
Nice, this helped me find the issue in |
…te-bound-assignments-on-fn-decl
…te-bound-assignments-on-fn-decl
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.
Sorry for the delay on coming back to this PR~
…s declared using element access expressions (microsoft#55183)
fixes #54811