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

41 lines
1.5 KiB
Plaintext

=== tests/cases/conformance/salsa/a.js ===
/// <reference path='./requires.d.ts' />
var mod1 = require('./mod1')
>mod1 : Symbol(mod1, Decl(a.js, 1, 3))
>require : Symbol(require, Decl(requires.d.ts, 0, 37))
>'./mod1' : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0))
mod1()
>mod1 : Symbol(mod1, Decl(a.js, 1, 3))
mod1.f() // error, not enough arguments
>mod1.f : Symbol(mod1.f, Decl(mod1.js, 1, 32))
>mod1 : Symbol(mod1, Decl(a.js, 1, 3))
>f : Symbol(mod1.f, Decl(mod1.js, 1, 32))
=== tests/cases/conformance/salsa/requires.d.ts ===
declare var module: { exports: any };
>module : Symbol(module, Decl(requires.d.ts, 0, 11))
>exports : Symbol(exports, Decl(requires.d.ts, 0, 21))
declare function require(name: string): any;
>require : Symbol(require, Decl(requires.d.ts, 0, 37))
>name : Symbol(name, Decl(requires.d.ts, 1, 25))
=== tests/cases/conformance/salsa/mod1.js ===
/// <reference path='./requires.d.ts' />
module.exports = function () { }
>module.exports : Symbol(module.exports, Decl(mod1.js, 0, 0))
>module : Symbol(export=, Decl(mod1.js, 0, 0))
>exports : Symbol(export=, Decl(mod1.js, 0, 0))
/** @param {number} a */
module.exports.f = function (a) { }
>module.exports.f : Symbol(f, Decl(mod1.js, 1, 32))
>module.exports : Symbol(f, Decl(mod1.js, 1, 32))
>module : Symbol(module, Decl(mod1.js, 0, 0))
>exports : Symbol(module.exports, Decl(mod1.js, 0, 0))
>f : Symbol(f, Decl(mod1.js, 1, 32))
>a : Symbol(a, Decl(mod1.js, 3, 29))