* 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
78 lines
3.3 KiB
Plaintext
78 lines
3.3 KiB
Plaintext
=== tests/cases/conformance/salsa/a.js ===
|
|
/// <reference path='./requires.d.ts' />
|
|
var mod1 = require('./mod1')
|
|
>mod1 : Symbol(mod1, Decl(a.js, 1, 3))
|
|
>require : Symbol(require, Decl(requires.d.ts, 0, 37))
|
|
>'./mod1' : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0))
|
|
|
|
mod1.justExport.toFixed()
|
|
>mod1.justExport.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
|
>mod1.justExport : Symbol(justExport, Decl(mod1.js, 2, 18))
|
|
>mod1 : Symbol(mod1, Decl(a.js, 1, 3))
|
|
>justExport : Symbol(justExport, Decl(mod1.js, 2, 18))
|
|
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
|
|
|
mod1.bothBefore.toFixed() // error, 'toFixed' not on 'string | number'
|
|
>mod1.bothBefore : Symbol(bothBefore, Decl(mod1.js, 3, 18), Decl(mod1.js, 0, 0))
|
|
>mod1 : Symbol(mod1, Decl(a.js, 1, 3))
|
|
>bothBefore : Symbol(bothBefore, Decl(mod1.js, 3, 18), Decl(mod1.js, 0, 0))
|
|
|
|
mod1.bothAfter.toFixed() // error, 'toFixed' not on 'string | number'
|
|
>mod1.bothAfter : Symbol(bothAfter, Decl(mod1.js, 4, 18), Decl(mod1.js, 6, 1))
|
|
>mod1 : Symbol(mod1, Decl(a.js, 1, 3))
|
|
>bothAfter : Symbol(bothAfter, Decl(mod1.js, 4, 18), Decl(mod1.js, 6, 1))
|
|
|
|
mod1.justProperty.length
|
|
>mod1.justProperty.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
|
>mod1.justProperty : Symbol(mod1.justProperty, Decl(mod1.js, 7, 35))
|
|
>mod1 : Symbol(mod1, Decl(a.js, 1, 3))
|
|
>justProperty : Symbol(mod1.justProperty, Decl(mod1.js, 7, 35))
|
|
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
|
|
|
=== tests/cases/conformance/salsa/requires.d.ts ===
|
|
declare var module: { exports: any };
|
|
>module : Symbol(module, Decl(requires.d.ts, 0, 11))
|
|
>exports : Symbol(exports, Decl(requires.d.ts, 0, 21))
|
|
|
|
declare function require(name: string): any;
|
|
>require : Symbol(require, Decl(requires.d.ts, 0, 37))
|
|
>name : Symbol(name, Decl(requires.d.ts, 1, 25))
|
|
|
|
=== tests/cases/conformance/salsa/mod1.js ===
|
|
/// <reference path='./requires.d.ts' />
|
|
module.exports.bothBefore = 'string'
|
|
>module.exports.bothBefore : Symbol(bothBefore, Decl(mod1.js, 3, 18), Decl(mod1.js, 0, 0))
|
|
>module.exports : Symbol(bothBefore, Decl(mod1.js, 0, 0))
|
|
>module : Symbol(module, Decl(mod1.js, 0, 0))
|
|
>exports : Symbol(module.exports, Decl(mod1.js, 0, 0))
|
|
>bothBefore : Symbol(bothBefore, Decl(mod1.js, 0, 0))
|
|
|
|
module.exports = {
|
|
>module.exports : Symbol(module.exports, Decl(mod1.js, 0, 0))
|
|
>module : Symbol(export=, Decl(mod1.js, 1, 36))
|
|
>exports : Symbol(export=, Decl(mod1.js, 1, 36))
|
|
|
|
justExport: 1,
|
|
>justExport : Symbol(justExport, Decl(mod1.js, 2, 18))
|
|
|
|
bothBefore: 2,
|
|
>bothBefore : Symbol(bothBefore, Decl(mod1.js, 3, 18))
|
|
|
|
bothAfter: 3,
|
|
>bothAfter : Symbol(bothAfter, Decl(mod1.js, 4, 18))
|
|
}
|
|
module.exports.bothAfter = 'string'
|
|
>module.exports.bothAfter : Symbol(bothAfter, Decl(mod1.js, 4, 18), Decl(mod1.js, 6, 1))
|
|
>module.exports : Symbol(bothAfter, Decl(mod1.js, 6, 1))
|
|
>module : Symbol(module, Decl(mod1.js, 0, 0))
|
|
>exports : Symbol(module.exports, Decl(mod1.js, 0, 0))
|
|
>bothAfter : Symbol(bothAfter, Decl(mod1.js, 6, 1))
|
|
|
|
module.exports.justProperty = 'string'
|
|
>module.exports.justProperty : Symbol(justProperty, Decl(mod1.js, 7, 35))
|
|
>module.exports : Symbol(justProperty, Decl(mod1.js, 7, 35))
|
|
>module : Symbol(module, Decl(mod1.js, 0, 0))
|
|
>exports : Symbol(module.exports, Decl(mod1.js, 0, 0))
|
|
>justProperty : Symbol(justProperty, Decl(mod1.js, 7, 35))
|
|
|