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

53 lines
2.1 KiB
Plaintext

=== tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportAssignedConstructorFunctionWithSub.js ===
/**
* @param {number} p
*/
module.exports = function (p) {
>module.exports = function (p) { this.t = 12 + p;} : { (p: number): void; new (p: number): exports; Sub: typeof Sub; }
>module.exports : { (p: number): void; new (p: number): exports; Sub: typeof Sub; }
>module : { exports: { (p: number): void; new (p: number): exports; Sub: typeof Sub; }; }
>exports : { (p: number): void; new (p: number): exports; Sub: typeof Sub; }
>function (p) { this.t = 12 + p;} : typeof exports
>p : number
this.t = 12 + p;
>this.t = 12 + p : number
>this.t : any
>this : this
>t : any
>12 + p : number
>12 : 12
>p : number
}
module.exports.Sub = function() {
>module.exports.Sub = function() { this.instance = new module.exports(10);} : typeof Sub
>module.exports.Sub : typeof Sub
>module.exports : { (p: number): void; new (p: number): exports; Sub: typeof Sub; }
>module : { exports: { (p: number): void; new (p: number): exports; Sub: typeof Sub; }; }
>exports : { (p: number): void; new (p: number): exports; Sub: typeof Sub; }
>Sub : typeof Sub
>function() { this.instance = new module.exports(10);} : typeof Sub
this.instance = new module.exports(10);
>this.instance = new module.exports(10) : exports
>this.instance : any
>this : this
>instance : any
>new module.exports(10) : exports
>module.exports : { (p: number): void; new (p: number): exports; Sub: typeof Sub; }
>module : { exports: { (p: number): void; new (p: number): exports; Sub: typeof Sub; }; }
>exports : { (p: number): void; new (p: number): exports; Sub: typeof Sub; }
>10 : 10
}
module.exports.Sub.prototype = { }
>module.exports.Sub.prototype = { } : {}
>module.exports.Sub.prototype : {}
>module.exports.Sub : typeof Sub
>module.exports : { (p: number): void; new (p: number): exports; Sub: typeof Sub; }
>module : { exports: { (p: number): void; new (p: number): exports; Sub: typeof Sub; }; }
>exports : { (p: number): void; new (p: number): exports; Sub: typeof Sub; }
>Sub : typeof Sub
>prototype : {}
>{ } : {}