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

70 lines
1.5 KiB
Plaintext

=== tests/cases/conformance/jsdoc/declarations/conn.js ===
/**
* @typedef {string | number} Whatever
*/
class Conn {
>Conn : Conn
constructor() {}
item = 3;
>item : number
>3 : 3
method() {}
>method : () => void
}
module.exports = Conn;
>module.exports = Conn : typeof Conn
>module.exports : typeof Conn
>module : { exports: typeof Conn; }
>exports : typeof Conn
>Conn : typeof Conn
=== tests/cases/conformance/jsdoc/declarations/usage.js ===
/**
* @typedef {import("./conn")} Conn
*/
class Wrap {
>Wrap : Wrap
/**
* @param {Conn} c
*/
constructor(c) {
>c : import("tests/cases/conformance/jsdoc/declarations/conn")
this.connItem = c.item;
>this.connItem = c.item : number
>this.connItem : any
>this : this
>connItem : any
>c.item : number
>c : import("tests/cases/conformance/jsdoc/declarations/conn")
>item : number
/** @type {import("./conn").Whatever} */
this.another = "";
>this.another = "" : ""
>this.another : import("tests/cases/conformance/jsdoc/declarations/conn").Whatever
>this : this
>another : import("tests/cases/conformance/jsdoc/declarations/conn").Whatever
>"" : ""
}
}
module.exports = {
>module.exports = { Wrap} : typeof module.exports
>module.exports : typeof module.exports
>module : { exports: typeof module.exports; }
>exports : typeof module.exports
>{ Wrap} : { Wrap: typeof Wrap; }
Wrap
>Wrap : typeof Wrap
};