Skip to content

Fix cross-file merge of assignment decl valueDeclaration #26918

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
merged 5 commits into from
Sep 16, 2018

Conversation

sandersn
Copy link
Member

@sandersn sandersn commented Sep 5, 2018

Previously mergeSymbol in the checker always updated valueDeclaration if target.valueDeclaration was an assignment declaration. The binder only updates target.valueDeclaration if it is an assignment declaration and source.valueDeclaration is not an assignment declaration.

Now the checker behaves the same way as the binder.

Fixes #26877

Previously mergeSymbol in the checker always updated valueDeclaration if
target.valueDeclaration was an assignment declaration. The binder only
updates target.valueDeclaration if it is an assignment declaration and
source.valueDeclaration is *not* an assignment declaration. Now the
checker behaves the same way as the binder.
@RyanCavanaugh
Copy link
Member

Baseline diff in jsContainerMergeJsContainer on CI

Makes commonjs merge with globals when appropriate.
/** CommonJS is *almost* a module -- no merges -- except that assignment declarations need to merge with globals. */
function mergeCommonJsSymbolTable(target: SymbolTable, source: SymbolTable) {
source.forEach((sourceSymbol, id) => {
if (target.has(id) && sourceSymbol.flags & SymbolFlags.Assignment) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talking with @weswigham, he pointed out that it would be better to store all the identifier-unbound declarations in a separate per-file commonJSGlobalAugmentations property that gets merged into globals instead of trying to filter here (there are plenty of symbols marked with Assignment that shouldn't necessarily merge with globals).

Instead of trying to filter these augmentations out of the normal symbol
table of commonjs modules.
@sandersn
Copy link
Member Author

All right, the new table is in. I dropped the "common" part since all JS files create global augmentations, and they all need to be merged, regardless of whether they are in a commonJS module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants