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

33 lines
938 B
Plaintext

=== tests/cases/conformance/jsdoc/declarations/index.js ===
const m = require("./exporter");
>m : typeof m
>require("./exporter") : typeof m
>require : any
>"./exporter" : "./exporter"
module.exports = m.default;
>module.exports = m.default : typeof m.default
>module.exports : typeof m.default
>module : { exports: typeof m.default; }
>exports : typeof m.default
>m.default : { (): void; memberName: string; }
>m : typeof m
>default : { (): void; memberName: string; }
module.exports.memberName = "thing";
>module.exports.memberName = "thing" : "thing"
>module.exports.memberName : string
>module.exports : typeof m.default
>module : { exports: typeof m.default; }
>exports : typeof m.default
>memberName : string
>"thing" : "thing"
=== tests/cases/conformance/jsdoc/declarations/exporter.js ===
function validate() {}
>validate : typeof validate
export default validate;
>validate : typeof validate