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

57 lines
1.7 KiB
Plaintext

=== tests/cases/conformance/jsdoc/use.js ===
/// <reference path='./types.d.ts'/>
/** @typedef {import("./mod1")} C
* @type {C} */
var c;
>c : Symbol(c, Decl(use.js, 3, 3))
c.chunk;
>c.chunk : Symbol(D.chunk, Decl(mod1.js, 2, 19))
>c : Symbol(c, Decl(use.js, 3, 3))
>chunk : Symbol(D.chunk, Decl(mod1.js, 2, 19))
const D = require("./mod1");
>D : Symbol(D, Decl(use.js, 6, 5))
>require : Symbol(require, Decl(types.d.ts, 0, 0))
>"./mod1" : Symbol("tests/cases/conformance/jsdoc/mod1", Decl(mod1.js, 0, 0))
/** @type {D} */
var d;
>d : Symbol(d, Decl(use.js, 8, 3))
d.chunk;
>d.chunk : Symbol(D.chunk, Decl(mod1.js, 2, 19))
>d : Symbol(d, Decl(use.js, 8, 3))
>chunk : Symbol(D.chunk, Decl(mod1.js, 2, 19))
=== tests/cases/conformance/jsdoc/types.d.ts ===
declare function require(name: string): any;
>require : Symbol(require, Decl(types.d.ts, 0, 0))
>name : Symbol(name, Decl(types.d.ts, 0, 25))
declare var exports: any;
>exports : Symbol(exports, Decl(types.d.ts, 1, 11))
declare var module: { exports: any };
>module : Symbol(module, Decl(types.d.ts, 2, 11))
>exports : Symbol(exports, Decl(types.d.ts, 2, 21))
=== tests/cases/conformance/jsdoc/mod1.js ===
/// <reference path='./types.d.ts'/>
class Chunk {
>Chunk : Symbol(Chunk, Decl(mod1.js, 0, 0))
constructor() {
this.chunk = 1;
>this.chunk : Symbol(Chunk.chunk, Decl(mod1.js, 2, 19))
>this : Symbol(Chunk, Decl(mod1.js, 0, 0))
>chunk : Symbol(Chunk.chunk, Decl(mod1.js, 2, 19))
}
}
module.exports = Chunk;
>module.exports : Symbol(module.exports, Decl(mod1.js, 0, 0))
>module : Symbol(export=, Decl(mod1.js, 5, 1))
>exports : Symbol(export=, Decl(mod1.js, 5, 1))
>Chunk : Symbol(Chunk, Decl(mod1.js, 0, 0))