-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Avoid trying to emit anonymous classish/expando functions as assignments #55472
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
Avoid trying to emit anonymous classish/expando functions as assignments #55472
Conversation
if (!context.remappedSymbolRefernces) { | ||
context.remappedSymbolRefernces = new Map(); | ||
} | ||
context.remappedSymbolRefernces.set(getSymbolId(type.symbol), symbol); // save name remapping as local name for target symbol |
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.
This is to handle the not-anonymous-but-still-an-expression case where you could use that local name to refer to the type of the expando-thing as a whole. Because it'd be odd if just adding a name to the function expression made this transform stop working.
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.
Is this is for cases like
const f = function g() { }
f.p = 1
Does remappedSymbolReferences record g
? When would g
show up in the declaration emit?
Edit: Looking at the test cases, it's actually g -> f
so that when a constructor function g
returns g
, it serialises as f
.
if (!context.remappedSymbolRefernces) { | ||
context.remappedSymbolRefernces = new Map(); | ||
} | ||
context.remappedSymbolRefernces.set(getSymbolId(type.symbol), symbol); // save name remapping as local name for target symbol |
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.
Is this is for cases like
const f = function g() { }
f.p = 1
Does remappedSymbolReferences record g
? When would g
show up in the declaration emit?
Edit: Looking at the test cases, it's actually g -> f
so that when a constructor function g
returns g
, it serialises as f
.
Fixes #55172