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

99 lines
2.3 KiB
Plaintext

=== tests/cases/conformance/jsdoc/mod2.js ===
const mod1 = require("./mod1");
>mod1 : typeof mod1
>require("./mod1") : typeof mod1
>require : any
>"./mod1" : "./mod1"
mod1.a;
>mod1.a : { x: string; }
>mod1 : typeof mod1
>a : { x: string; }
mod1.b;
>mod1.b : { x: string; }
>mod1 : typeof mod1
>b : { x: string; }
mod1.c;
>mod1.c : { x: string; }
>mod1 : typeof mod1
>c : { x: string; }
mod1.d;
>mod1.d : typeof mod1."d"
>mod1 : typeof mod1
>d : typeof mod1."d"
mod1.d.e;
>mod1.d.e : number
>mod1.d : typeof mod1."d"
>mod1 : typeof mod1
>d : typeof mod1."d"
>e : number
mod1.default;
>mod1.default : { x: string; }
>mod1 : typeof mod1
>default : { x: string; }
=== tests/cases/conformance/jsdoc/mod1.js ===
exports.a = { x: "x" };
>exports.a = { x: "x" } : { x: string; }
>exports.a : { x: string; }
>exports : typeof import("tests/cases/conformance/jsdoc/mod1")
>a : { x: string; }
>{ x: "x" } : { x: string; }
>x : string
>"x" : "x"
exports["b"] = { x: "x" };
>exports["b"] = { x: "x" } : { x: string; }
>exports["b"] : { x: string; }
>exports : typeof import("tests/cases/conformance/jsdoc/mod1")
>"b" : "b"
>{ x: "x" } : { x: string; }
>x : string
>"x" : "x"
exports["default"] = { x: "x" };
>exports["default"] = { x: "x" } : { x: string; }
>exports["default"] : { x: string; }
>exports : typeof import("tests/cases/conformance/jsdoc/mod1")
>"default" : "default"
>{ x: "x" } : { x: string; }
>x : string
>"x" : "x"
module.exports["c"] = { x: "x" };
>module.exports["c"] = { x: "x" } : { x: string; }
>module.exports["c"] : { x: string; }
>module.exports : typeof module.exports
>module : { exports: typeof module.exports; }
>exports : typeof module.exports
>"c" : "c"
>{ x: "x" } : { x: string; }
>x : string
>"x" : "x"
module["exports"]["d"] = {};
>module["exports"]["d"] = {} : typeof "d"
>module["exports"]["d"] : typeof "d"
>module["exports"] : typeof module.exports
>module : { exports: typeof module.exports; }
>"exports" : "exports"
>"d" : "d"
>{} : {}
module["exports"]["d"].e = 0;
>module["exports"]["d"].e = 0 : 0
>module["exports"]["d"].e : number
>module["exports"]["d"] : typeof "d"
>module["exports"] : typeof module.exports
>module : { exports: typeof module.exports; }
>"exports" : "exports"
>"d" : "d"
>e : number
>0 : 0