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

50 lines
1.7 KiB
Plaintext

=== tests/cases/conformance/salsa/main.js ===
const { hardline } = require('./second').nested;
>hardline : { type: string; }
>require('./second').nested : typeof import("tests/cases/conformance/salsa/first")
>require('./second') : { nested: typeof import("tests/cases/conformance/salsa/first"); }
>require : any
>'./second' : "./second"
>nested : typeof import("tests/cases/conformance/salsa/first")
hardline
>hardline : { type: string; }
=== tests/cases/conformance/salsa/first.js ===
// #41422, based on prettier's exports
const hardline = { type: "hard" }
>hardline : { type: string; }
>{ type: "hard" } : { type: string; }
>type : string
>"hard" : "hard"
module.exports = {
>module.exports = { hardline} : typeof module.exports
>module.exports : typeof module.exports
>module : { exports: typeof module.exports; }
>exports : typeof module.exports
>{ hardline} : { hardline: { type: string; }; }
hardline
>hardline : { type: string; }
}
=== tests/cases/conformance/salsa/second.js ===
module.exports = {
>module.exports = { nested: require('./first')} : { nested: typeof import("tests/cases/conformance/salsa/first"); }
>module.exports : { nested: typeof import("tests/cases/conformance/salsa/first"); }
>module : { exports: { nested: typeof import("tests/cases/conformance/salsa/first"); }; }
>exports : { nested: typeof import("tests/cases/conformance/salsa/first"); }
>{ nested: require('./first')} : { nested: typeof import("tests/cases/conformance/salsa/first"); }
nested: require('./first')
>nested : typeof import("tests/cases/conformance/salsa/first")
>require('./first') : typeof import("tests/cases/conformance/salsa/first")
>require : any
>'./first' : "./first"
};