* 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
29 lines
772 B
Plaintext
29 lines
772 B
Plaintext
=== tests/cases/compiler/file.ts ===
|
|
class Foo {
|
|
>Foo : Symbol(Foo, Decl(file.ts, 0, 0))
|
|
|
|
x: number;
|
|
>x : Symbol(Foo.x, Decl(file.ts, 0, 11))
|
|
}
|
|
|
|
declare global {
|
|
>global : Symbol(global, Decl(file.ts, 2, 1))
|
|
|
|
var module: any; // Just here to remove unrelated error from test
|
|
>module : Symbol(module, Decl(file.ts, 5, 7))
|
|
}
|
|
|
|
export = Foo;
|
|
>Foo : Symbol(Foo, Decl(file.ts, 0, 0))
|
|
|
|
=== tests/cases/compiler/something.js ===
|
|
/** @typedef {typeof import("./file")} Foo */
|
|
|
|
/** @typedef {(foo: Foo) => string} FooFun */
|
|
|
|
module.exports = /** @type {FooFun} */(void 0);
|
|
>module.exports : Symbol(module.exports, Decl(something.js, 0, 0))
|
|
>module : Symbol(export=, Decl(something.js, 0, 0))
|
|
>exports : Symbol(export=, Decl(something.js, 0, 0))
|
|
|