Skip to content

Commit aba932a

Browse files
authored
Create synthetic exports symbol for commonjs module (microsoft#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
1 parent 79ed041 commit aba932a

File tree

229 files changed

+875
-852
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

229 files changed

+875
-852
lines changed

src/compiler/checker.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -8768,8 +8768,15 @@ namespace ts {
87688768
}
87698769
if (symbol.flags & SymbolFlags.ModuleExports) {
87708770
const fileSymbol = getSymbolOfNode(getSourceFileOfNode(symbol.valueDeclaration));
8771+
const result = createSymbol(fileSymbol.flags, "exports" as __String);
8772+
result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : [];
8773+
result.parent = symbol;
8774+
result.target = fileSymbol;
8775+
if (fileSymbol.valueDeclaration) result.valueDeclaration = fileSymbol.valueDeclaration;
8776+
if (fileSymbol.members) result.members = new Map(fileSymbol.members);
8777+
if (fileSymbol.exports) result.exports = new Map(fileSymbol.exports);
87718778
const members = createSymbolTable();
8772-
members.set("exports" as __String, fileSymbol);
8779+
members.set("exports" as __String, result);
87738780
return createAnonymousType(symbol, members, emptyArray, emptyArray, undefined, undefined);
87748781
}
87758782
// Handle catch clause variables

tests/baselines/reference/binderUninitializedModuleExportsAssignment.symbols

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var loop2 = loop1;
88
>loop1 : Symbol(loop1, Decl(loop.js, 0, 3))
99

1010
module.exports = loop2;
11-
>module.exports : Symbol("tests/cases/conformance/salsa/loop", Decl(loop.js, 0, 0))
11+
>module.exports : Symbol(module.exports, Decl(loop.js, 0, 0))
1212
>module : Symbol(export=, Decl(loop.js, 1, 18))
1313
>exports : Symbol(export=, Decl(loop.js, 1, 18))
1414
>loop2 : Symbol(loop2, Decl(loop.js, 1, 3))

tests/baselines/reference/binderUninitializedModuleExportsAssignment.types

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var loop2 = loop1;
1010
module.exports = loop2;
1111
>module.exports = loop2 : any
1212
>module.exports : any
13-
>module : { "\"tests/cases/conformance/salsa/loop\"": any; }
13+
>module : { exports: any; }
1414
>exports : any
1515
>loop2 : any
1616

tests/baselines/reference/callbackCrossModule.symbols

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @return {any} I don't even know what this should return
55
*/
66
module.exports = C
7-
>module.exports : Symbol("tests/cases/conformance/jsdoc/mod1", Decl(mod1.js, 0, 0))
7+
>module.exports : Symbol(module.exports, Decl(mod1.js, 0, 0))
88
>module : Symbol(export=, Decl(mod1.js, 0, 0))
99
>exports : Symbol(export=, Decl(mod1.js, 0, 0))
1010
>C : Symbol(C, Decl(mod1.js, 4, 18))

tests/baselines/reference/callbackCrossModule.types

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
module.exports = C
77
>module.exports = C : typeof C
88
>module.exports : typeof C
9-
>module : { "\"tests/cases/conformance/jsdoc/mod1\"": typeof C; }
9+
>module : { exports: typeof C; }
1010
>exports : typeof C
1111
>C : typeof C
1212

tests/baselines/reference/checkExportsObjectAssignProperty.symbols

+10-10
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ Object.defineProperty(module.exports, "thing", { value: "yes", writable: true })
202202
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
203203
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
204204
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
205-
>module.exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
205+
>module.exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
206206
>module : Symbol(module, Decl(mod2.js, 0, 22))
207-
>exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
207+
>exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
208208
>"thing" : Symbol(thing, Decl(mod2.js, 0, 0))
209209
>value : Symbol(value, Decl(mod2.js, 0, 48))
210210
>writable : Symbol(writable, Decl(mod2.js, 0, 62))
@@ -213,9 +213,9 @@ Object.defineProperty(module.exports, "readonlyProp", { value: "Smith", writable
213213
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
214214
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
215215
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
216-
>module.exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
216+
>module.exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
217217
>module : Symbol(module, Decl(mod2.js, 0, 22))
218-
>exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
218+
>exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
219219
>"readonlyProp" : Symbol(readonlyProp, Decl(mod2.js, 0, 81))
220220
>value : Symbol(value, Decl(mod2.js, 1, 55))
221221
>writable : Symbol(writable, Decl(mod2.js, 1, 71))
@@ -224,9 +224,9 @@ Object.defineProperty(module.exports, "rwAccessors", { get() { return 98122 }, s
224224
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
225225
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
226226
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
227-
>module.exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
227+
>module.exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
228228
>module : Symbol(module, Decl(mod2.js, 0, 22))
229-
>exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
229+
>exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
230230
>"rwAccessors" : Symbol(rwAccessors, Decl(mod2.js, 1, 91))
231231
>get : Symbol(get, Decl(mod2.js, 2, 54))
232232
>set : Symbol(set, Decl(mod2.js, 2, 78))
@@ -236,19 +236,19 @@ Object.defineProperty(module.exports, "readonlyAccessor", { get() { return 21.75
236236
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
237237
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
238238
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
239-
>module.exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
239+
>module.exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
240240
>module : Symbol(module, Decl(mod2.js, 0, 22))
241-
>exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
241+
>exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
242242
>"readonlyAccessor" : Symbol(readonlyAccessor, Decl(mod2.js, 2, 104))
243243
>get : Symbol(get, Decl(mod2.js, 3, 59))
244244

245245
Object.defineProperty(module.exports, "setonlyAccessor", {
246246
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
247247
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
248248
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
249-
>module.exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
249+
>module.exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
250250
>module : Symbol(module, Decl(mod2.js, 0, 22))
251-
>exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
251+
>exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
252252
>"setonlyAccessor" : Symbol(setonlyAccessor, Decl(mod2.js, 3, 86))
253253

254254
/** @param {string} str */

tests/baselines/reference/checkExportsObjectAssignProperty.types

+15-15
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ Object.defineProperty(module.exports, "thing", { value: "yes", writable: true })
255255
>Object.defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
256256
>Object : ObjectConstructor
257257
>defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
258-
>module.exports : typeof import("tests/cases/conformance/jsdoc/mod2")
259-
>module : { "\"tests/cases/conformance/jsdoc/mod2\"": typeof import("tests/cases/conformance/jsdoc/mod2"); }
260-
>exports : typeof import("tests/cases/conformance/jsdoc/mod2")
258+
>module.exports : typeof module.exports
259+
>module : { exports: typeof module.exports; }
260+
>exports : typeof module.exports
261261
>"thing" : "thing"
262262
>{ value: "yes", writable: true } : { value: string; writable: true; }
263263
>value : string
@@ -270,9 +270,9 @@ Object.defineProperty(module.exports, "readonlyProp", { value: "Smith", writable
270270
>Object.defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
271271
>Object : ObjectConstructor
272272
>defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
273-
>module.exports : typeof import("tests/cases/conformance/jsdoc/mod2")
274-
>module : { "\"tests/cases/conformance/jsdoc/mod2\"": typeof import("tests/cases/conformance/jsdoc/mod2"); }
275-
>exports : typeof import("tests/cases/conformance/jsdoc/mod2")
273+
>module.exports : typeof module.exports
274+
>module : { exports: typeof module.exports; }
275+
>exports : typeof module.exports
276276
>"readonlyProp" : "readonlyProp"
277277
>{ value: "Smith", writable: false } : { value: string; writable: false; }
278278
>value : string
@@ -285,9 +285,9 @@ Object.defineProperty(module.exports, "rwAccessors", { get() { return 98122 }, s
285285
>Object.defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
286286
>Object : ObjectConstructor
287287
>defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
288-
>module.exports : typeof import("tests/cases/conformance/jsdoc/mod2")
289-
>module : { "\"tests/cases/conformance/jsdoc/mod2\"": typeof import("tests/cases/conformance/jsdoc/mod2"); }
290-
>exports : typeof import("tests/cases/conformance/jsdoc/mod2")
288+
>module.exports : typeof module.exports
289+
>module : { exports: typeof module.exports; }
290+
>exports : typeof module.exports
291291
>"rwAccessors" : "rwAccessors"
292292
>{ get() { return 98122 }, set(_) { /*ignore*/ } } : { get(): number; set(_: any): void; }
293293
>get : () => number
@@ -300,9 +300,9 @@ Object.defineProperty(module.exports, "readonlyAccessor", { get() { return 21.75
300300
>Object.defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
301301
>Object : ObjectConstructor
302302
>defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
303-
>module.exports : typeof import("tests/cases/conformance/jsdoc/mod2")
304-
>module : { "\"tests/cases/conformance/jsdoc/mod2\"": typeof import("tests/cases/conformance/jsdoc/mod2"); }
305-
>exports : typeof import("tests/cases/conformance/jsdoc/mod2")
303+
>module.exports : typeof module.exports
304+
>module : { exports: typeof module.exports; }
305+
>exports : typeof module.exports
306306
>"readonlyAccessor" : "readonlyAccessor"
307307
>{ get() { return 21.75 } } : { get(): number; }
308308
>get : () => number
@@ -313,9 +313,9 @@ Object.defineProperty(module.exports, "setonlyAccessor", {
313313
>Object.defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
314314
>Object : ObjectConstructor
315315
>defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
316-
>module.exports : typeof import("tests/cases/conformance/jsdoc/mod2")
317-
>module : { "\"tests/cases/conformance/jsdoc/mod2\"": typeof import("tests/cases/conformance/jsdoc/mod2"); }
318-
>exports : typeof import("tests/cases/conformance/jsdoc/mod2")
316+
>module.exports : typeof module.exports
317+
>module : { exports: typeof module.exports; }
318+
>exports : typeof module.exports
319319
>"setonlyAccessor" : "setonlyAccessor"
320320
>{ /** @param {string} str */ set(str) { this.rwAccessors = Number(str) }} : { set(str: string): void; }
321321

tests/baselines/reference/checkExportsObjectAssignPrototypeProperty.symbols

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Object.defineProperty(Person.prototype, "setonlyAccessor", {
170170
}
171171
});
172172
module.exports = Person;
173-
>module.exports : Symbol("tests/cases/conformance/jsdoc/mod1", Decl(mod1.js, 0, 0))
173+
>module.exports : Symbol(module.exports, Decl(mod1.js, 0, 0))
174174
>module : Symbol(export=, Decl(mod1.js, 19, 3))
175175
>exports : Symbol(export=, Decl(mod1.js, 19, 3))
176176
>Person : Symbol(Person, Decl(mod1.js, 0, 0))

tests/baselines/reference/checkExportsObjectAssignPrototypeProperty.types

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ Object.defineProperty(Person.prototype, "setonlyAccessor", {
214214
module.exports = Person;
215215
>module.exports = Person : typeof Person
216216
>module.exports : typeof Person
217-
>module : { "\"tests/cases/conformance/jsdoc/mod1\"": typeof Person; }
217+
>module : { exports: typeof Person; }
218218
>exports : typeof Person
219219
>Person : typeof Person
220220

tests/baselines/reference/checkJsTypeDefNoUnusedLocalMarked.symbols

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export = Foo;
2222
/** @typedef {(foo: Foo) => string} FooFun */
2323

2424
module.exports = /** @type {FooFun} */(void 0);
25-
>module.exports : Symbol("tests/cases/compiler/something", Decl(something.js, 0, 0))
25+
>module.exports : Symbol(module.exports, Decl(something.js, 0, 0))
2626
>module : Symbol(export=, Decl(something.js, 0, 0))
2727
>exports : Symbol(export=, Decl(something.js, 0, 0))
2828

tests/baselines/reference/checkJsTypeDefNoUnusedLocalMarked.types

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export = Foo;
2424
module.exports = /** @type {FooFun} */(void 0);
2525
>module.exports = /** @type {FooFun} */(void 0) : (foo: Foo) => string
2626
>module.exports : (foo: typeof import("tests/cases/compiler/file")) => string
27-
>module : { "\"tests/cases/compiler/something\"": (foo: typeof import("tests/cases/compiler/file")) => string; }
27+
>module : { exports: (foo: typeof import("tests/cases/compiler/file")) => string; }
2828
>exports : (foo: typeof import("tests/cases/compiler/file")) => string
2929
>(void 0) : FooFun
3030
>void 0 : undefined

tests/baselines/reference/checkObjectDefineProperty.symbols

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ match(() => expected, (x = expected) => void 0);
196196
>expected : Symbol(expected, Decl(index.js, 32, 5))
197197

198198
module.exports = x;
199-
>module.exports : Symbol("tests/cases/conformance/jsdoc/index", Decl(index.js, 0, 0))
199+
>module.exports : Symbol(module.exports, Decl(index.js, 0, 0))
200200
>module : Symbol(export=, Decl(index.js, 41, 48))
201201
>exports : Symbol(export=, Decl(index.js, 41, 48))
202202
>x : Symbol(x, Decl(index.js, 0, 5), Decl(index.js, 1, 22), Decl(index.js, 2, 22), Decl(index.js, 3, 22), Decl(index.js, 4, 22) ... and 2 more)

tests/baselines/reference/checkObjectDefineProperty.types

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ match(() => expected, (x = expected) => void 0);
249249
module.exports = x;
250250
>module.exports = x : typeof x
251251
>module.exports : typeof x
252-
>module : { "\"tests/cases/conformance/jsdoc/index\"": typeof x; }
252+
>module : { exports: typeof x; }
253253
>exports : typeof x
254254
>x : typeof x
255255

tests/baselines/reference/commonJSReexport.symbols

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ const hardline = { type: "hard" }
1717
>type : Symbol(type, Decl(first.js, 2, 18))
1818

1919
module.exports = {
20-
>module.exports : Symbol("tests/cases/conformance/salsa/first", Decl(first.js, 0, 0))
20+
>module.exports : Symbol(module.exports, Decl(first.js, 0, 0))
2121
>module : Symbol(module, Decl(first.js, 2, 33))
22-
>exports : Symbol("tests/cases/conformance/salsa/first", Decl(first.js, 0, 0))
22+
>exports : Symbol(module.exports, Decl(first.js, 0, 0))
2323

2424
hardline
2525
>hardline : Symbol(hardline, Decl(first.js, 3, 18))
@@ -28,7 +28,7 @@ module.exports = {
2828

2929
=== tests/cases/conformance/salsa/second.js ===
3030
module.exports = {
31-
>module.exports : Symbol("tests/cases/conformance/salsa/second", Decl(second.js, 0, 0))
31+
>module.exports : Symbol(module.exports, Decl(second.js, 0, 0))
3232
>module : Symbol(export=, Decl(second.js, 0, 0))
3333
>exports : Symbol(export=, Decl(second.js, 0, 0))
3434

tests/baselines/reference/commonJSReexport.types

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ const hardline = { type: "hard" }
2020
>"hard" : "hard"
2121

2222
module.exports = {
23-
>module.exports = { hardline} : typeof import("tests/cases/conformance/salsa/first")
24-
>module.exports : typeof import("tests/cases/conformance/salsa/first")
25-
>module : { "\"tests/cases/conformance/salsa/first\"": typeof import("tests/cases/conformance/salsa/first"); }
26-
>exports : typeof import("tests/cases/conformance/salsa/first")
23+
>module.exports = { hardline} : typeof module.exports
24+
>module.exports : typeof module.exports
25+
>module : { exports: typeof module.exports; }
26+
>exports : typeof module.exports
2727
>{ hardline} : { hardline: { type: string; }; }
2828

2929
hardline
@@ -35,7 +35,7 @@ module.exports = {
3535
module.exports = {
3636
>module.exports = { nested: require('./first')} : { nested: typeof import("tests/cases/conformance/salsa/first"); }
3737
>module.exports : { nested: typeof import("tests/cases/conformance/salsa/first"); }
38-
>module : { "\"tests/cases/conformance/salsa/second\"": { nested: typeof import("tests/cases/conformance/salsa/first"); }; }
38+
>module : { exports: { nested: typeof import("tests/cases/conformance/salsa/first"); }; }
3939
>exports : { nested: typeof import("tests/cases/conformance/salsa/first"); }
4040
>{ nested: require('./first')} : { nested: typeof import("tests/cases/conformance/salsa/first"); }
4141

tests/baselines/reference/commonJsIsolatedModules.symbols

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
=== tests/cases/compiler/index.js ===
22
module.exports = {}
3-
>module.exports : Symbol("tests/cases/compiler/index", Decl(index.js, 0, 0))
3+
>module.exports : Symbol(module.exports, Decl(index.js, 0, 0))
44
>module : Symbol(module, Decl(index.js, 0, 0))
5-
>exports : Symbol("tests/cases/compiler/index", Decl(index.js, 0, 0))
5+
>exports : Symbol(module.exports, Decl(index.js, 0, 0))
66

77
var x = 1
88
>x : Symbol(x, Decl(index.js, 1, 3))

tests/baselines/reference/commonJsIsolatedModules.types

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
=== tests/cases/compiler/index.js ===
22
module.exports = {}
3-
>module.exports = {} : typeof import("tests/cases/compiler/index")
4-
>module.exports : typeof import("tests/cases/compiler/index")
5-
>module : { "\"tests/cases/compiler/index\"": typeof import("tests/cases/compiler/index"); }
6-
>exports : typeof import("tests/cases/compiler/index")
3+
>module.exports = {} : typeof module.exports
4+
>module.exports : typeof module.exports
5+
>module : { exports: typeof module.exports; }
6+
>exports : typeof module.exports
77
>{} : {}
88

99
var x = 1

tests/baselines/reference/constructorFunctions2.symbols

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function A() { this.id = 1; }
5656
>id : Symbol(A.id, Decl(other.js, 0, 14))
5757

5858
module.exports = A;
59-
>module.exports : Symbol("tests/cases/conformance/salsa/other", Decl(other.js, 0, 0))
59+
>module.exports : Symbol(module.exports, Decl(other.js, 0, 0))
6060
>module : Symbol(export=, Decl(other.js, 0, 29))
6161
>exports : Symbol(export=, Decl(other.js, 0, 29))
6262
>A : Symbol(A, Decl(other.js, 0, 0))

tests/baselines/reference/constructorFunctions2.types

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function A() { this.id = 1; }
7171
module.exports = A;
7272
>module.exports = A : typeof A
7373
>module.exports : typeof A
74-
>module : { "\"tests/cases/conformance/salsa/other\"": typeof A; }
74+
>module : { exports: typeof A; }
7575
>exports : typeof A
7676
>A : typeof A
7777

tests/baselines/reference/contextualTypedSpecialAssignment.symbols

+4-4
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ module.exports.y = {
103103
>module.exports.y : Symbol(y, Decl(test.js, 45, 9))
104104
>module.exports : Symbol(y, Decl(test.js, 45, 9))
105105
>module : Symbol(module, Decl(test.js, 45, 9))
106-
>exports : Symbol("tests/cases/conformance/salsa/test", Decl(test.js, 0, 0))
106+
>exports : Symbol(module.exports, Decl(test.js, 0, 0))
107107
>y : Symbol(y, Decl(test.js, 45, 9))
108108

109109
status: "done",
@@ -115,9 +115,9 @@ module.exports.y = {
115115
}
116116
module.exports.y
117117
>module.exports.y : Symbol(y, Decl(test.js, 45, 9))
118-
>module.exports : Symbol("tests/cases/conformance/salsa/test", Decl(test.js, 0, 0))
118+
>module.exports : Symbol(module.exports, Decl(test.js, 0, 0))
119119
>module : Symbol(module, Decl(test.js, 45, 9))
120-
>exports : Symbol("tests/cases/conformance/salsa/test", Decl(test.js, 0, 0))
120+
>exports : Symbol(module.exports, Decl(test.js, 0, 0))
121121
>y : Symbol(y, Decl(test.js, 45, 9))
122122

123123
// prototype-property assignment
@@ -165,7 +165,7 @@ F.prototype = {
165165
// module.exports assignment
166166
/** @type {{ status: 'done', m(n: number): void }} */
167167
module.exports = {
168-
>module.exports : Symbol("tests/cases/conformance/salsa/mod", Decl(mod.js, 0, 0))
168+
>module.exports : Symbol(module.exports, Decl(mod.js, 0, 0))
169169
>module : Symbol(export=, Decl(mod.js, 0, 0))
170170
>exports : Symbol(export=, Decl(mod.js, 0, 0))
171171

tests/baselines/reference/contextualTypedSpecialAssignment.types

+7-7
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ exports.x
118118
module.exports.y = {
119119
>module.exports.y = { status: "done", m(n) { }} : { status: "done"; m(n: number): void; }
120120
>module.exports.y : DoneStatus
121-
>module.exports : typeof import("tests/cases/conformance/salsa/test")
122-
>module : { "\"tests/cases/conformance/salsa/test\"": typeof import("tests/cases/conformance/salsa/test"); }
123-
>exports : typeof import("tests/cases/conformance/salsa/test")
121+
>module.exports : typeof module.exports
122+
>module : { exports: typeof module.exports; }
123+
>exports : typeof module.exports
124124
>y : DoneStatus
125125
>{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; }
126126

@@ -134,9 +134,9 @@ module.exports.y = {
134134
}
135135
module.exports.y
136136
>module.exports.y : DoneStatus
137-
>module.exports : typeof import("tests/cases/conformance/salsa/test")
138-
>module : { "\"tests/cases/conformance/salsa/test\"": typeof import("tests/cases/conformance/salsa/test"); }
139-
>exports : typeof import("tests/cases/conformance/salsa/test")
137+
>module.exports : typeof module.exports
138+
>module : { exports: typeof module.exports; }
139+
>exports : typeof module.exports
140140
>y : DoneStatus
141141

142142
// prototype-property assignment
@@ -192,7 +192,7 @@ F.prototype = {
192192
module.exports = {
193193
>module.exports = { status: "done", m(n) { }} : { status: 'done'; m(n: number): void; }
194194
>module.exports : { status: "done"; m(n: number): void; }
195-
>module : { "\"tests/cases/conformance/salsa/mod\"": { status: "done"; m(n: number): void; }; }
195+
>module : { exports: { status: "done"; m(n: number): void; }; }
196196
>exports : { status: "done"; m(n: number): void; }
197197
>{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; }
198198

0 commit comments

Comments
 (0)