aba932aefa
* 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
79 lines
2.7 KiB
Plaintext
79 lines
2.7 KiB
Plaintext
=== tests/cases/conformance/jsdoc/use.js ===
|
|
var mod = require('./mod1.js');
|
|
>mod : { Baz: typeof Baz; Bar: typeof mod.Bar; Quid: number; } | { Quack: number; Bar: typeof mod.Bar; Quid: number; }
|
|
>require('./mod1.js') : { Baz: typeof Baz; Bar: typeof mod.Bar; Quid: number; } | { Quack: number; Bar: typeof mod.Bar; Quid: number; }
|
|
>require : any
|
|
>'./mod1.js' : "./mod1.js"
|
|
|
|
/** @type {import("./mod1.js").Baz} */
|
|
var b;
|
|
>b : number
|
|
|
|
/** @type {mod.Baz} */
|
|
var bb;
|
|
>bb : number
|
|
|
|
var bbb = new mod.Baz();
|
|
>bbb : any
|
|
>new mod.Baz() : any
|
|
>mod.Baz : any
|
|
>mod : { Baz: typeof Baz; Bar: typeof mod.Bar; Quid: number; } | { Quack: number; Bar: typeof mod.Bar; Quid: number; }
|
|
>Baz : any
|
|
|
|
=== tests/cases/conformance/jsdoc/mod1.js ===
|
|
// error
|
|
|
|
/** @typedef {number} Foo */
|
|
class Foo { } // should error
|
|
>Foo : Foo
|
|
|
|
/** @typedef {number} Bar */
|
|
exports.Bar = class { }
|
|
>exports.Bar = class { } : typeof Bar
|
|
>exports.Bar : typeof Bar
|
|
>exports : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; }
|
|
>Bar : typeof Bar
|
|
>class { } : typeof Bar
|
|
|
|
/** @typedef {number} Baz */
|
|
module.exports = {
|
|
>module.exports = { Baz: class { }} : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; }
|
|
>module.exports : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; }
|
|
>module : { exports: { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; }; }
|
|
>exports : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; }
|
|
>{ Baz: class { }} : { Baz: typeof Baz; }
|
|
|
|
Baz: class { }
|
|
>Baz : typeof Baz
|
|
>class { } : typeof Baz
|
|
}
|
|
|
|
// ok
|
|
|
|
/** @typedef {number} Qux */
|
|
var Qux = 2;
|
|
>Qux : number
|
|
>2 : 2
|
|
|
|
/** @typedef {number} Quid */
|
|
exports.Quid = 2;
|
|
>exports.Quid = 2 : 2
|
|
>exports.Quid : number
|
|
>exports : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; }
|
|
>Quid : number
|
|
>2 : 2
|
|
|
|
/** @typedef {number} Quack */
|
|
module.exports = {
|
|
>module.exports = { Quack: 2} : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; }
|
|
>module.exports : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; }
|
|
>module : { exports: { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; }; }
|
|
>exports : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; }
|
|
>{ Quack: 2} : { Quack: number; }
|
|
|
|
Quack: 2
|
|
>Quack : number
|
|
>2 : 2
|
|
}
|
|
|