Skip to content

Conversation

@weswigham
Copy link
Member

Fixes #55172

@weswigham weswigham requested review from gabritto and sandersn August 22, 2023 21:15
@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Aug 22, 2023
if (!context.remappedSymbolRefernces) {
context.remappedSymbolRefernces = new Map();
}
context.remappedSymbolRefernces.set(getSymbolId(type.symbol), symbol); // save name remapping as local name for target symbol
Copy link
Member Author

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.

Copy link
Member

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
Copy link
Member

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.

@weswigham weswigham merged commit 5ce34ca into microsoft:main Aug 28, 2023
@weswigham weswigham deleted the js-declarations-global-file branch August 28, 2023 19:16
snovader pushed a commit to EG-A-S/TypeScript that referenced this pull request Sep 23, 2023
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tsc with allowJs reports TS9005 error for anonymous constructor functions

3 participants