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

208 lines
4.9 KiB
Plaintext

=== tests/cases/conformance/salsa/test.js ===
/** @typedef {{
status: 'done'
m(n: number): void
}} DoneStatus */
// property assignment
var ns = {}
>ns : typeof ns
>{} : {}
/** @type {DoneStatus} */
ns.x = {
>ns.x = { status: 'done', m(n) { }} : { status: "done"; m(n: number): void; }
>ns.x : DoneStatus
>ns : typeof ns
>x : DoneStatus
>{ status: 'done', m(n) { }} : { status: "done"; m(n: number): void; }
status: 'done',
>status : "done"
>'done' : "done"
m(n) { }
>m : (n: number) => void
>n : number
}
ns.x = {
>ns.x = { status: 'done', m(n) { }} : { status: "done"; m(n: number): void; }
>ns.x : DoneStatus
>ns : typeof ns
>x : DoneStatus
>{ status: 'done', m(n) { }} : { status: "done"; m(n: number): void; }
status: 'done',
>status : "done"
>'done' : "done"
m(n) { }
>m : (n: number) => void
>n : number
}
ns.x
>ns.x : DoneStatus
>ns : typeof ns
>x : DoneStatus
// this-property assignment
class Thing {
>Thing : Thing
constructor() {
/** @type {DoneStatus} */
this.s = {
>this.s = { status: 'done', m(n) { } } : { status: "done"; m(n: number): void; }
>this.s : DoneStatus
>this : this
>s : DoneStatus
>{ status: 'done', m(n) { } } : { status: "done"; m(n: number): void; }
status: 'done',
>status : "done"
>'done' : "done"
m(n) { }
>m : (n: number) => void
>n : number
}
}
fail() {
>fail : () => void
this.s = {
>this.s = { status: 'done', m(n) { } } : { status: "done"; m(n: number): void; }
>this.s : DoneStatus
>this : this
>s : DoneStatus
>{ status: 'done', m(n) { } } : { status: "done"; m(n: number): void; }
status: 'done',
>status : "done"
>'done' : "done"
m(n) { }
>m : (n: number) => void
>n : number
}
}
}
// exports-property assignment
/** @type {DoneStatus} */
exports.x = {
>exports.x = { status: "done", m(n) { }} : { status: "done"; m(n: number): void; }
>exports.x : DoneStatus
>exports : typeof import("tests/cases/conformance/salsa/test")
>x : DoneStatus
>{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; }
status: "done",
>status : "done"
>"done" : "done"
m(n) { }
>m : (n: number) => void
>n : number
}
exports.x
>exports.x : DoneStatus
>exports : typeof import("tests/cases/conformance/salsa/test")
>x : DoneStatus
/** @type {DoneStatus} */
module.exports.y = {
>module.exports.y = { status: "done", m(n) { }} : { status: "done"; m(n: number): void; }
>module.exports.y : DoneStatus
>module.exports : typeof module.exports
>module : { exports: typeof module.exports; }
>exports : typeof module.exports
>y : DoneStatus
>{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; }
status: "done",
>status : "done"
>"done" : "done"
m(n) { }
>m : (n: number) => void
>n : number
}
module.exports.y
>module.exports.y : DoneStatus
>module.exports : typeof module.exports
>module : { exports: typeof module.exports; }
>exports : typeof module.exports
>y : DoneStatus
// prototype-property assignment
/** @type {DoneStatus} */
Thing.prototype.x = {
>Thing.prototype.x = { status: 'done', m(n) { }} : { status: "done"; m(n: number): void; }
>Thing.prototype.x : DoneStatus
>Thing.prototype : Thing
>Thing : typeof Thing
>prototype : Thing
>x : DoneStatus
>{ status: 'done', m(n) { }} : { status: "done"; m(n: number): void; }
status: 'done',
>status : "done"
>'done' : "done"
m(n) { }
>m : (n: number) => void
>n : number
}
Thing.prototype.x
>Thing.prototype.x : DoneStatus
>Thing.prototype : Thing
>Thing : typeof Thing
>prototype : Thing
>x : DoneStatus
// prototype assignment
function F() {
>F : typeof F
}
/** @type {DoneStatus} */
F.prototype = {
>F.prototype = { status: "done", m(n) { }} : { status: "done"; m(n: number): void; }
>F.prototype : DoneStatus
>F : typeof F
>prototype : DoneStatus
>{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; }
status: "done",
>status : "done"
>"done" : "done"
m(n) { }
>m : (n: number) => void
>n : number
}
=== tests/cases/conformance/salsa/mod.js ===
// module.exports assignment
/** @type {{ status: 'done', m(n: number): void }} */
module.exports = {
>module.exports = { status: "done", m(n) { }} : { status: 'done'; m(n: number): void; }
>module.exports : { status: "done"; m(n: number): void; }
>module : { exports: { status: "done"; m(n: number): void; }; }
>exports : { status: "done"; m(n: number): void; }
>{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; }
status: "done",
>status : "done"
>"done" : "done"
m(n) { }
>m : (n: number) => void
>n : number
}