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

44 lines
1.2 KiB
Plaintext

=== /test.js ===
class Abcde {
>Abcde : Symbol(Abcde, Decl(test.js, 0, 0), Decl(index.ts, 2, 25))
/** @type {string} */
x;
>x : Symbol(Abcde.x, Decl(test.js, 0, 13))
}
module.exports = {
>module.exports : Symbol("/test.js", Decl(test.js, 0, 0), Decl(index.ts, 0, 31))
>module : Symbol(module, Decl(test.js, 3, 1))
>exports : Symbol("/test.js", Decl(test.js, 0, 0), Decl(index.ts, 0, 31))
Abcde
>Abcde : Symbol(Abcde, Decl(test.js, 5, 18))
};
=== /index.ts ===
import { Abcde } from "./test";
>Abcde : Symbol(Abcde, Decl(index.ts, 0, 8))
declare module "./test" {
>"./test" : Symbol("/test", Decl(test.js, 0, 0), Decl(index.ts, 0, 31))
interface Abcde { b: string }
>Abcde : Symbol(Abcde, Decl(test.js, 0, 0), Decl(index.ts, 2, 25))
>b : Symbol(Abcde.b, Decl(index.ts, 3, 19))
}
new Abcde().x;
>new Abcde().x : Symbol(Abcde.x, Decl(test.js, 0, 13))
>Abcde : Symbol(Abcde, Decl(index.ts, 0, 8))
>x : Symbol(Abcde.x, Decl(test.js, 0, 13))
// Bug: the type meaning from /test.js does not
// propagate through the object literal export.
const x: Abcde = { b: "" };
>x : Symbol(x, Decl(index.ts, 10, 5))
>Abcde : Symbol(Abcde, Decl(index.ts, 0, 8))
>b : Symbol(b, Decl(index.ts, 10, 18))