Skip to content

Fix cross-file merge of assignment decl valueDeclaration - #26918

Merged
Nathan Shively-Sanders (sandersn) merged 5 commits into
masterfrom
fix-assignment-decl-cross-file-merge
Sep 16, 2018
Merged

Nathan Shively-Sanders (sandersn) merged 5 commits into
masterfrom
fix-assignment-decl-cross-file-merge

Conversation

@sandersn

Copy link
Copy Markdown
Member

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

Baseline diff in jsContainerMergeJsContainer on CI

Makes commonjs merge with globals when appropriate.
Comment thread src/compiler/checker.ts Outdated
/** 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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Talking with Wesley Wigham (@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
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants