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
48 lines
1.5 KiB
Plaintext
48 lines
1.5 KiB
Plaintext
=== tests/cases/conformance/salsa/a.js ===
|
|
/// <reference path='./requires.d.ts' />
|
|
var mod1 = require('./mod1')
|
|
>mod1 : { (): void; f: (a: number) => void; }
|
|
>require('./mod1') : { (): void; f: (a: number) => void; }
|
|
>require : (name: string) => any
|
|
>'./mod1' : "./mod1"
|
|
|
|
mod1()
|
|
>mod1() : void
|
|
>mod1 : { (): void; f: (a: number) => void; }
|
|
|
|
mod1.f() // error, not enough arguments
|
|
>mod1.f() : void
|
|
>mod1.f : (a: number) => void
|
|
>mod1 : { (): void; f: (a: number) => void; }
|
|
>f : (a: number) => void
|
|
|
|
=== 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 = function () { }
|
|
>module.exports = function () { } : { (): void; f: (a: number) => void; }
|
|
>module.exports : { (): void; f: (a: number) => void; }
|
|
>module : { exports: { (): void; f: (a: number) => void; }; }
|
|
>exports : { (): void; f: (a: number) => void; }
|
|
>function () { } : () => void
|
|
|
|
/** @param {number} a */
|
|
module.exports.f = function (a) { }
|
|
>module.exports.f = function (a) { } : (a: number) => void
|
|
>module.exports.f : (a: number) => void
|
|
>module.exports : { (): void; f: (a: number) => void; }
|
|
>module : { exports: { (): void; f: (a: number) => void; }; }
|
|
>exports : { (): void; f: (a: number) => void; }
|
|
>f : (a: number) => void
|
|
>function (a) { } : (a: number) => void
|
|
>a : number
|
|
|