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

36 lines
1 KiB
Plaintext

=== tests/cases/conformance/jsdoc/declarations/index.js ===
const{ a, m } = require("./something").o;
>a : Symbol(a, Decl(index.js, 0, 6))
>m : Symbol(m, Decl(index.js, 0, 9))
>require("./something").o : Symbol(o, Decl(something.ts, 0, 12))
>require : Symbol(require)
>"./something" : Symbol("tests/cases/conformance/jsdoc/declarations/something", Decl(something.ts, 0, 0))
>o : Symbol(o, Decl(something.ts, 0, 12))
const thing = a + m
>thing : Symbol(thing, Decl(index.js, 2, 5))
>a : Symbol(a, Decl(index.js, 0, 6))
>m : Symbol(m, Decl(index.js, 0, 9))
module.exports = {
>module.exports : Symbol(module.exports, Decl(index.js, 0, 0))
>module : Symbol(module, Decl(index.js, 2, 19))
>exports : Symbol(module.exports, Decl(index.js, 0, 0))
thing
>thing : Symbol(thing, Decl(index.js, 4, 18))
};
=== tests/cases/conformance/jsdoc/declarations/something.ts ===
export const o = {
>o : Symbol(o, Decl(something.ts, 0, 12))
a: 1,
>a : Symbol(a, Decl(something.ts, 0, 18))
m: 1
>m : Symbol(m, Decl(something.ts, 1, 9))
}