TypeScript/tests/baselines/reference/commonJSReexport.symbols
Nathan Shively-Sanders aba932aefa
Create synthetic exports symbol for commonjs module (#42655)
* Commonjs module:create synthetic exports symbol

Previously, the `module` identifier in commonjs modules got a synthetic
type with a single property `exports`. The exports property reused the
file's symbol, which, for a module file, gives the correct exported
properties.

However, the name of this symbol was still the filename of the file, not
`exports`. This PR creates a synthetic symbol for `exports` by copying
in a similar way to esModuleInterop's `default` symbol in
`resolveESModuleSymbol` (although the intent there is to strip off
signatures from the symbol).

* correct parent of synthetic symbol
2021-02-05 10:56:03 -08:00

42 lines
1.3 KiB
Plaintext

=== tests/cases/conformance/salsa/main.js ===
const { hardline } = require('./second').nested;
>hardline : Symbol(hardline, Decl(main.js, 0, 7))
>require('./second').nested : Symbol(nested, Decl(second.js, 0, 18))
>require : Symbol(require)
>'./second' : Symbol("tests/cases/conformance/salsa/second", Decl(second.js, 0, 0))
>nested : Symbol(nested, Decl(second.js, 0, 18))
hardline
>hardline : Symbol(hardline, Decl(main.js, 0, 7))
=== tests/cases/conformance/salsa/first.js ===
// #41422, based on prettier's exports
const hardline = { type: "hard" }
>hardline : Symbol(hardline, Decl(first.js, 2, 5))
>type : Symbol(type, Decl(first.js, 2, 18))
module.exports = {
>module.exports : Symbol(module.exports, Decl(first.js, 0, 0))
>module : Symbol(module, Decl(first.js, 2, 33))
>exports : Symbol(module.exports, Decl(first.js, 0, 0))
hardline
>hardline : Symbol(hardline, Decl(first.js, 3, 18))
}
=== tests/cases/conformance/salsa/second.js ===
module.exports = {
>module.exports : Symbol(module.exports, Decl(second.js, 0, 0))
>module : Symbol(export=, Decl(second.js, 0, 0))
>exports : Symbol(export=, Decl(second.js, 0, 0))
nested: require('./first')
>nested : Symbol(nested, Decl(second.js, 0, 18))
>require : Symbol(require)
>'./first' : Symbol("tests/cases/conformance/salsa/first", Decl(first.js, 0, 0))
};