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

70 lines
2.4 KiB
Plaintext

=== tests/cases/conformance/jsdoc/declarations/index.js ===
export {}; // flag file as module
No type information for this code./**
No type information for this code. * @typedef {string | number | symbol} PropName
No type information for this code. */
No type information for this code.
No type information for this code./**
No type information for this code. * Callback
No type information for this code. *
No type information for this code. * @callback NumberToStringCb
No type information for this code. * @param {number} a
No type information for this code. * @returns {string}
No type information for this code. */
No type information for this code.
No type information for this code./**
No type information for this code. * @template T
No type information for this code. * @typedef {T & {name: string}} MixinName
No type information for this code. */
No type information for this code.
No type information for this code./**
No type information for this code. * Identity function
No type information for this code. *
No type information for this code. * @template T
No type information for this code. * @callback Identity
No type information for this code. * @param {T} x
No type information for this code. * @returns {T}
No type information for this code. */
No type information for this code.
No type information for this code.=== tests/cases/conformance/jsdoc/declarations/mixed.js ===
/**
* @typedef {{x: string} | number | LocalThing | ExportedThing} SomeType
*/
/**
* @param {number} x
* @returns {SomeType}
*/
function doTheThing(x) {
>doTheThing : Symbol(doTheThing, Decl(mixed.js, 0, 0))
>x : Symbol(x, Decl(mixed.js, 7, 20))
return {x: ""+x};
>x : Symbol(x, Decl(mixed.js, 8, 12))
>x : Symbol(x, Decl(mixed.js, 7, 20))
}
class ExportedThing {
>ExportedThing : Symbol(ExportedThing, Decl(mixed.js, 9, 1))
z = "ok"
>z : Symbol(ExportedThing.z, Decl(mixed.js, 10, 21))
}
module.exports = {
>module.exports : Symbol(module.exports, Decl(mixed.js, 0, 0))
>module : Symbol(module, Decl(mixed.js, 12, 1))
>exports : Symbol(module.exports, Decl(mixed.js, 0, 0))
doTheThing,
>doTheThing : Symbol(doTheThing, Decl(mixed.js, 13, 18))
ExportedThing,
>ExportedThing : Symbol(ExportedThing, Decl(mixed.js, 14, 15))
};
class LocalThing {
>LocalThing : Symbol(LocalThing, Decl(mixed.js, 16, 2))
y = "ok"
>y : Symbol(LocalThing.y, Decl(mixed.js, 17, 18))
}