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
93 lines
4.3 KiB
Plaintext
93 lines
4.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(mod1.justExport, Decl(mod1.js, 1, 36))
|
|
>mod1 : Symbol(mod1, Decl(a.js, 1, 3))
|
|
>justExport : Symbol(mod1.justExport, Decl(mod1.js, 1, 36))
|
|
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
|
|
|
mod1.bothBefore.toFixed() // error
|
|
>mod1.bothBefore : Symbol(mod1.bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0))
|
|
>mod1 : Symbol(mod1, Decl(a.js, 1, 3))
|
|
>bothBefore : Symbol(mod1.bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0))
|
|
|
|
mod1.bothAfter.toFixed()
|
|
>mod1.bothAfter : Symbol(mod1.bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1))
|
|
>mod1 : Symbol(mod1, Decl(a.js, 1, 3))
|
|
>bothAfter : Symbol(mod1.bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1))
|
|
|
|
mod1.justProperty.length
|
|
>mod1.justProperty.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
|
>mod1.justProperty : Symbol(mod1.justProperty, Decl(mod1.js, 9, 35))
|
|
>mod1 : Symbol(mod1, Decl(a.js, 1, 3))
|
|
>justProperty : Symbol(mod1.justProperty, Decl(mod1.js, 9, 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, 2, 16), Decl(mod1.js, 0, 0))
|
|
>module.exports : Symbol(bothBefore, Decl(mod1.js, 2, 16), 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, 2, 16), Decl(mod1.js, 0, 0))
|
|
|
|
A.justExport = 4
|
|
>A.justExport : Symbol(A.justExport, Decl(mod1.js, 1, 36))
|
|
>A : Symbol(A, Decl(mod1.js, 5, 18), Decl(mod1.js, 1, 36), Decl(mod1.js, 2, 16), Decl(mod1.js, 3, 16))
|
|
>justExport : Symbol(A.justExport, Decl(mod1.js, 1, 36))
|
|
|
|
A.bothBefore = 2
|
|
>A.bothBefore : Symbol(bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0))
|
|
>A : Symbol(A, Decl(mod1.js, 5, 18), Decl(mod1.js, 1, 36), Decl(mod1.js, 2, 16), Decl(mod1.js, 3, 16))
|
|
>bothBefore : Symbol(bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0))
|
|
|
|
A.bothAfter = 3
|
|
>A.bothAfter : Symbol(bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1))
|
|
>A : Symbol(A, Decl(mod1.js, 5, 18), Decl(mod1.js, 1, 36), Decl(mod1.js, 2, 16), Decl(mod1.js, 3, 16))
|
|
>bothAfter : Symbol(bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1))
|
|
|
|
module.exports = A
|
|
>module.exports : Symbol(module.exports, Decl(mod1.js, 0, 0))
|
|
>module : Symbol(export=, Decl(mod1.js, 4, 15))
|
|
>exports : Symbol(export=, Decl(mod1.js, 4, 15))
|
|
>A : Symbol(A, Decl(mod1.js, 5, 18), Decl(mod1.js, 1, 36), Decl(mod1.js, 2, 16), Decl(mod1.js, 3, 16))
|
|
|
|
function A() {
|
|
>A : Symbol(A, Decl(mod1.js, 5, 18), Decl(mod1.js, 1, 36), Decl(mod1.js, 2, 16), Decl(mod1.js, 3, 16))
|
|
|
|
this.p = 1
|
|
>this.p : Symbol(A.p, Decl(mod1.js, 6, 14))
|
|
>this : Symbol(A, Decl(mod1.js, 5, 18), Decl(mod1.js, 1, 36), Decl(mod1.js, 2, 16), Decl(mod1.js, 3, 16))
|
|
>p : Symbol(A.p, Decl(mod1.js, 6, 14))
|
|
}
|
|
module.exports.bothAfter = 'string'
|
|
>module.exports.bothAfter : Symbol(bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1))
|
|
>module.exports : Symbol(bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1))
|
|
>module : Symbol(module, Decl(mod1.js, 0, 0))
|
|
>exports : Symbol(module.exports, Decl(mod1.js, 0, 0))
|
|
>bothAfter : Symbol(bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1))
|
|
|
|
module.exports.justProperty = 'string'
|
|
>module.exports.justProperty : Symbol(justProperty, Decl(mod1.js, 9, 35))
|
|
>module.exports : Symbol(justProperty, Decl(mod1.js, 9, 35))
|
|
>module : Symbol(module, Decl(mod1.js, 0, 0))
|
|
>exports : Symbol(module.exports, Decl(mod1.js, 0, 0))
|
|
>justProperty : Symbol(justProperty, Decl(mod1.js, 9, 35))
|
|
|