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

66 lines
1.3 KiB
Plaintext

=== tests/cases/conformance/salsa/index.js ===
/// <reference path='node.d.ts' />
const C = require("./semver")
>C : typeof C
>require("./semver") : typeof C
>require : (name: string) => any
>"./semver" : "./semver"
var two = C.f(1)
>two : any
>C.f(1) : any
>C.f : (n: any) => any
>C : typeof C
>f : (n: any) => any
>1 : 1
var c = new C
>c : C
>new C : C
>C : typeof C
=== tests/cases/conformance/salsa/node.d.ts ===
declare function require(name: string): any;
>require : (name: string) => any
>name : string
declare var exports: any;
>exports : any
declare var module: { exports: any };
>module : { exports: any; }
>exports : any
=== tests/cases/conformance/salsa/semver.js ===
/// <reference path='node.d.ts' />
exports = module.exports = C
>exports = module.exports = C : typeof C
>exports : typeof C
>module.exports = C : typeof C
>module.exports : typeof C
>module : { exports: typeof C; }
>exports : typeof C
>C : typeof C
exports.f = n => n + 1
>exports.f = n => n + 1 : (n: any) => any
>exports.f : (n: any) => any
>exports : typeof C
>f : (n: any) => any
>n => n + 1 : (n: any) => any
>n : any
>n + 1 : any
>n : any
>1 : 1
function C() {
>C : typeof C
this.p = 1
>this.p = 1 : 1
>this.p : any
>this : this
>p : any
>1 : 1
}