TypeScript/tests/baselines/reference/moduleExportsElementAccessAssignment.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

75 lines
2.7 KiB
Plaintext

=== tests/cases/conformance/jsdoc/mod2.js ===
const mod1 = require("./mod1");
>mod1 : Symbol(mod1, Decl(mod2.js, 0, 5))
>require : Symbol(require)
>"./mod1" : Symbol(mod1, Decl(mod1.js, 0, 0))
mod1.a;
>mod1.a : Symbol(mod1.a, Decl(mod1.js, 0, 0))
>mod1 : Symbol(mod1, Decl(mod2.js, 0, 5))
>a : Symbol(mod1.a, Decl(mod1.js, 0, 0))
mod1.b;
>mod1.b : Symbol(mod1["b"], Decl(mod1.js, 0, 23))
>mod1 : Symbol(mod1, Decl(mod2.js, 0, 5))
>b : Symbol(mod1["b"], Decl(mod1.js, 0, 23))
mod1.c;
>mod1.c : Symbol(mod1["c"], Decl(mod1.js, 2, 32))
>mod1 : Symbol(mod1, Decl(mod2.js, 0, 5))
>c : Symbol(mod1["c"], Decl(mod1.js, 2, 32))
mod1.d;
>mod1.d : Symbol(mod1["d"], Decl(mod1.js, 3, 33), Decl(mod1.js, 5, 18))
>mod1 : Symbol(mod1, Decl(mod2.js, 0, 5))
>d : Symbol(mod1["d"], Decl(mod1.js, 3, 33), Decl(mod1.js, 5, 18))
mod1.d.e;
>mod1.d.e : Symbol(mod1["d"].e, Decl(mod1.js, 4, 28))
>mod1.d : Symbol(mod1["d"], Decl(mod1.js, 3, 33), Decl(mod1.js, 5, 18))
>mod1 : Symbol(mod1, Decl(mod2.js, 0, 5))
>d : Symbol(mod1["d"], Decl(mod1.js, 3, 33), Decl(mod1.js, 5, 18))
>e : Symbol(mod1["d"].e, Decl(mod1.js, 4, 28))
mod1.default;
>mod1.default : Symbol(mod1.default, Decl(mod1.js, 1, 26))
>mod1 : Symbol(mod1, Decl(mod2.js, 0, 5))
>default : Symbol(mod1.default, Decl(mod1.js, 1, 26))
=== tests/cases/conformance/jsdoc/mod1.js ===
exports.a = { x: "x" };
>exports.a : Symbol(a, Decl(mod1.js, 0, 0))
>exports : Symbol(a, Decl(mod1.js, 0, 0))
>a : Symbol(a, Decl(mod1.js, 0, 0))
>x : Symbol(x, Decl(mod1.js, 0, 13))
exports["b"] = { x: "x" };
>exports : Symbol("tests/cases/conformance/jsdoc/mod1", Decl(mod1.js, 0, 0))
>"b" : Symbol("b", Decl(mod1.js, 0, 23))
>x : Symbol(x, Decl(mod1.js, 1, 16))
exports["default"] = { x: "x" };
>exports : Symbol("tests/cases/conformance/jsdoc/mod1", Decl(mod1.js, 0, 0))
>"default" : Symbol("default", Decl(mod1.js, 1, 26))
>x : Symbol(x, Decl(mod1.js, 2, 22))
module.exports["c"] = { x: "x" };
>module.exports : Symbol(module.exports, Decl(mod1.js, 0, 0))
>module : Symbol(module, Decl(mod1.js, 2, 32))
>exports : Symbol(module.exports, Decl(mod1.js, 0, 0))
>"c" : Symbol("c", Decl(mod1.js, 2, 32))
>x : Symbol(x, Decl(mod1.js, 3, 23))
module["exports"]["d"] = {};
>module : Symbol(module, Decl(mod1.js, 2, 32))
>"exports" : Symbol(module.exports, Decl(mod1.js, 0, 0))
>"d" : Symbol("d", Decl(mod1.js, 3, 33), Decl(mod1.js, 5, 18))
module["exports"]["d"].e = 0;
>module["exports"]["d"].e : Symbol("d".e, Decl(mod1.js, 4, 28))
>module : Symbol(module, Decl(mod1.js, 2, 32))
>"exports" : Symbol(module.exports, Decl(mod1.js, 0, 0))
>"d" : Symbol("d", Decl(mod1.js, 3, 33), Decl(mod1.js, 5, 18))
>e : Symbol("d".e, Decl(mod1.js, 4, 28))