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
97 lines
4.4 KiB
Plaintext
97 lines
4.4 KiB
Plaintext
=== tests/cases/conformance/salsa/a.js ===
|
|
/// <reference path='./requires.d.ts' />
|
|
var mod1 = require('./mod1')
|
|
>mod1 : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }
|
|
>require('./mod1') : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }
|
|
>require : (name: string) => any
|
|
>'./mod1' : "./mod1"
|
|
|
|
mod1.justExport.toFixed()
|
|
>mod1.justExport.toFixed() : string
|
|
>mod1.justExport.toFixed : (fractionDigits?: number) => string
|
|
>mod1.justExport : number
|
|
>mod1 : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }
|
|
>justExport : number
|
|
>toFixed : (fractionDigits?: number) => string
|
|
|
|
mod1.bothBefore.toFixed() // error, 'toFixed' not on 'string | number'
|
|
>mod1.bothBefore.toFixed() : any
|
|
>mod1.bothBefore.toFixed : any
|
|
>mod1.bothBefore : string | number
|
|
>mod1 : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }
|
|
>bothBefore : string | number
|
|
>toFixed : any
|
|
|
|
mod1.bothAfter.toFixed() // error, 'toFixed' not on 'string | number'
|
|
>mod1.bothAfter.toFixed() : any
|
|
>mod1.bothAfter.toFixed : any
|
|
>mod1.bothAfter : string | number
|
|
>mod1 : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }
|
|
>bothAfter : string | number
|
|
>toFixed : any
|
|
|
|
mod1.justProperty.length
|
|
>mod1.justProperty.length : number
|
|
>mod1.justProperty : string
|
|
>mod1 : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }
|
|
>justProperty : string
|
|
>length : number
|
|
|
|
=== tests/cases/conformance/salsa/requires.d.ts ===
|
|
declare var module: { exports: any };
|
|
>module : { exports: any; }
|
|
>exports : any
|
|
|
|
declare function require(name: string): any;
|
|
>require : (name: string) => any
|
|
>name : string
|
|
|
|
=== tests/cases/conformance/salsa/mod1.js ===
|
|
/// <reference path='./requires.d.ts' />
|
|
module.exports.bothBefore = 'string'
|
|
>module.exports.bothBefore = 'string' : "string"
|
|
>module.exports.bothBefore : string | number
|
|
>module.exports : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }
|
|
>module : { exports: { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }; }
|
|
>exports : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }
|
|
>bothBefore : string | number
|
|
>'string' : "string"
|
|
|
|
module.exports = {
|
|
>module.exports = { justExport: 1, bothBefore: 2, bothAfter: 3,} : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }
|
|
>module.exports : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }
|
|
>module : { exports: { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }; }
|
|
>exports : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }
|
|
>{ justExport: 1, bothBefore: 2, bothAfter: 3,} : { justExport: number; bothBefore: number; bothAfter: number; }
|
|
|
|
justExport: 1,
|
|
>justExport : number
|
|
>1 : 1
|
|
|
|
bothBefore: 2,
|
|
>bothBefore : number
|
|
>2 : 2
|
|
|
|
bothAfter: 3,
|
|
>bothAfter : number
|
|
>3 : 3
|
|
}
|
|
module.exports.bothAfter = 'string'
|
|
>module.exports.bothAfter = 'string' : "string"
|
|
>module.exports.bothAfter : string | number
|
|
>module.exports : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }
|
|
>module : { exports: { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }; }
|
|
>exports : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }
|
|
>bothAfter : string | number
|
|
>'string' : "string"
|
|
|
|
module.exports.justProperty = 'string'
|
|
>module.exports.justProperty = 'string' : "string"
|
|
>module.exports.justProperty : string
|
|
>module.exports : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }
|
|
>module : { exports: { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }; }
|
|
>exports : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }
|
|
>justProperty : string
|
|
>'string' : "string"
|
|
|