Skip to content

Fix getExpandoSymbol for already-expando symbols#36457

Merged
sandersn merged 2 commits intomasterfrom
fix-import-type-to-module-exports-of-class-expr
Jan 27, 2020
Merged

Fix getExpandoSymbol for already-expando symbols#36457
sandersn merged 2 commits intomasterfrom
fix-import-type-to-module-exports-of-class-expr

Conversation

@sandersn
Copy link
Member

@sandersn sandersn commented Jan 27, 2020

getExpandoSymbol is intended to get the symbol of the expando in a declaration like

var C = class {
}

However, when this occurs in a module.exports assignment, alias resolution already jumps to the exported symbol -- in this case the expando symbol:

// @filename: first.js
module.exports = class {
}
// @filename: other.js
/* @type {import("./first")} */
var C

getExpandoSymbol is then called on class { } instead of module.exports = class { }.

Previously, getExpandoSymbol would incorrectly treat class { } the same as the export assignment and get the expando ... from the expando
itself. This resulted in merging the expando with itself, which causes bogus errors in webpack and could cause other problems.

Now getExpandoSymbol checks that the declaration is not already an expando.

Fixes #34809

getExpandoSymbol is intended to get the symbol of the expando in a
declaration like

```js
var C = class {
}
```

However, when this occurs in a `module.exports` assignment, alias
resolution already jumps to the exported symbol -- in this case the
expando symbol:

``js
// @filename: first.js
module.exports = class {
}
// @filename: other.js
/* @type {import("./first")} */
var C
```

`getExpandoSymbol` is then called on `class { }` instead of
`module.exports = class { }`.

Previously, `getExpandoSymbol` would incorrectly treat `class { }` the
same as the export assignment and get the expando ... from the expando
itself. This resulted in merging the expando with itself, which causes
bogus errors and could cause other problems.

Now `getExpandoSymbol` checks that the expando "initializer" is
different from the declaration.
Check the declaration directly instead of the initialiser.
@sandersn sandersn merged commit 757e670 into master Jan 27, 2020
@sandersn sandersn deleted the fix-import-type-to-module-exports-of-class-expr branch January 27, 2020 20:33
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Circular typedef references causes incorrect error

3 participants