* 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
47 lines
867 B
Plaintext
47 lines
867 B
Plaintext
=== /test.js ===
|
|
class Abcde {
|
|
>Abcde : Abcde
|
|
|
|
/** @type {string} */
|
|
x;
|
|
>x : string
|
|
}
|
|
|
|
module.exports = {
|
|
>module.exports = { Abcde} : typeof module."./test"
|
|
>module.exports : typeof module."./test"
|
|
>module : { exports: typeof module."./test"; }
|
|
>exports : typeof module."./test"
|
|
>{ Abcde} : { Abcde: typeof Abcde; }
|
|
|
|
Abcde
|
|
>Abcde : typeof Abcde
|
|
|
|
};
|
|
|
|
=== /index.ts ===
|
|
import { Abcde } from "./test";
|
|
>Abcde : typeof Abcde
|
|
|
|
declare module "./test" {
|
|
>"./test" : typeof import("/test")
|
|
|
|
interface Abcde { b: string }
|
|
>b : string
|
|
}
|
|
|
|
new Abcde().x;
|
|
>new Abcde().x : string
|
|
>new Abcde() : Abcde
|
|
>Abcde : typeof Abcde
|
|
>x : string
|
|
|
|
// Bug: the type meaning from /test.js does not
|
|
// propagate through the object literal export.
|
|
const x: Abcde = { b: "" };
|
|
>x : Abcde
|
|
>{ b: "" } : { b: string; }
|
|
>b : string
|
|
>"" : ""
|
|
|