forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Alias for
module.exports.x = x
(microsoft#40228)
* Alias for `module.exports.x = x` This fixes microsoft#40155 in a surprisingly small amount of code. * Treat any aliasable expression as an alias * test internal references to exported class
- Loading branch information
Showing
47 changed files
with
588 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
tests/baselines/reference/commonJSImportClassExpression.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//// [tests/cases/conformance/salsa/commonJSImportClassExpression.ts] //// | ||
|
||
//// [main.js] | ||
const { K } = require("./mod1"); | ||
/** @param {K} k */ | ||
function f(k) { | ||
k.values() | ||
} | ||
|
||
//// [mod1.js] | ||
exports.K = class K { | ||
values() { | ||
} | ||
}; | ||
|
||
|
||
//// [mod1.js] | ||
"use strict"; | ||
exports.K = /** @class */ (function () { | ||
function K() { | ||
} | ||
K.prototype.values = function () { | ||
}; | ||
return K; | ||
}()); | ||
//// [main.js] | ||
"use strict"; | ||
var K = require("./mod1").K; | ||
/** @param {K} k */ | ||
function f(k) { | ||
k.values(); | ||
} | ||
|
||
|
||
//// [mod1.d.ts] | ||
export class K { | ||
values(): void; | ||
} | ||
//// [main.d.ts] | ||
export {}; |
29 changes: 29 additions & 0 deletions
29
tests/baselines/reference/commonJSImportClassExpression.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
=== tests/cases/conformance/salsa/main.js === | ||
const { K } = require("./mod1"); | ||
>K : Symbol(K, Decl(main.js, 0, 7)) | ||
>require : Symbol(require) | ||
>"./mod1" : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) | ||
|
||
/** @param {K} k */ | ||
function f(k) { | ||
>f : Symbol(f, Decl(main.js, 0, 32)) | ||
>k : Symbol(k, Decl(main.js, 2, 11)) | ||
|
||
k.values() | ||
>k.values : Symbol(K.values, Decl(mod1.js, 0, 21)) | ||
>k : Symbol(k, Decl(main.js, 2, 11)) | ||
>values : Symbol(K.values, Decl(mod1.js, 0, 21)) | ||
} | ||
|
||
=== tests/cases/conformance/salsa/mod1.js === | ||
exports.K = class K { | ||
>exports.K : Symbol(K, Decl(mod1.js, 0, 0)) | ||
>exports : Symbol(K, Decl(mod1.js, 0, 0)) | ||
>K : Symbol(K, Decl(mod1.js, 0, 0)) | ||
>K : Symbol(K, Decl(mod1.js, 0, 11)) | ||
|
||
values() { | ||
>values : Symbol(K.values, Decl(mod1.js, 0, 21)) | ||
} | ||
}; | ||
|
33 changes: 33 additions & 0 deletions
33
tests/baselines/reference/commonJSImportClassExpression.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
=== tests/cases/conformance/salsa/main.js === | ||
const { K } = require("./mod1"); | ||
>K : typeof K | ||
>require("./mod1") : typeof import("tests/cases/conformance/salsa/mod1") | ||
>require : any | ||
>"./mod1" : "./mod1" | ||
|
||
/** @param {K} k */ | ||
function f(k) { | ||
>f : (k: K) => void | ||
>k : K | ||
|
||
k.values() | ||
>k.values() : void | ||
>k.values : () => void | ||
>k : K | ||
>values : () => void | ||
} | ||
|
||
=== tests/cases/conformance/salsa/mod1.js === | ||
exports.K = class K { | ||
>exports.K = class K { values() { }} : typeof K | ||
>exports.K : typeof K | ||
>exports : typeof import("tests/cases/conformance/salsa/mod1") | ||
>K : typeof K | ||
>class K { values() { }} : typeof K | ||
>K : typeof K | ||
|
||
values() { | ||
>values : () => void | ||
} | ||
}; | ||
|
44 changes: 44 additions & 0 deletions
44
tests/baselines/reference/commonJSImportClassTypeReference.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//// [tests/cases/conformance/salsa/commonJSImportClassTypeReference.ts] //// | ||
|
||
//// [main.js] | ||
const { K } = require("./mod1"); | ||
/** @param {K} k */ | ||
function f(k) { | ||
k.values() | ||
} | ||
|
||
//// [mod1.js] | ||
class K { | ||
values() { | ||
return new K() | ||
} | ||
} | ||
exports.K = K; | ||
|
||
|
||
//// [mod1.js] | ||
"use strict"; | ||
var K = /** @class */ (function () { | ||
function K() { | ||
} | ||
K.prototype.values = function () { | ||
return new K(); | ||
}; | ||
return K; | ||
}()); | ||
exports.K = K; | ||
//// [main.js] | ||
"use strict"; | ||
var K = require("./mod1").K; | ||
/** @param {K} k */ | ||
function f(k) { | ||
k.values(); | ||
} | ||
|
||
|
||
//// [mod1.d.ts] | ||
export class K { | ||
values(): K; | ||
} | ||
//// [main.d.ts] | ||
export {}; |
34 changes: 34 additions & 0 deletions
34
tests/baselines/reference/commonJSImportClassTypeReference.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
=== tests/cases/conformance/salsa/main.js === | ||
const { K } = require("./mod1"); | ||
>K : Symbol(K, Decl(main.js, 0, 7)) | ||
>require : Symbol(require) | ||
>"./mod1" : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) | ||
|
||
/** @param {K} k */ | ||
function f(k) { | ||
>f : Symbol(f, Decl(main.js, 0, 32)) | ||
>k : Symbol(k, Decl(main.js, 2, 11)) | ||
|
||
k.values() | ||
>k.values : Symbol(K.values, Decl(mod1.js, 0, 9)) | ||
>k : Symbol(k, Decl(main.js, 2, 11)) | ||
>values : Symbol(K.values, Decl(mod1.js, 0, 9)) | ||
} | ||
|
||
=== tests/cases/conformance/salsa/mod1.js === | ||
class K { | ||
>K : Symbol(K, Decl(mod1.js, 0, 0)) | ||
|
||
values() { | ||
>values : Symbol(K.values, Decl(mod1.js, 0, 9)) | ||
|
||
return new K() | ||
>K : Symbol(K, Decl(mod1.js, 0, 0)) | ||
} | ||
} | ||
exports.K = K; | ||
>exports.K : Symbol(K, Decl(mod1.js, 4, 1)) | ||
>exports : Symbol(K, Decl(mod1.js, 4, 1)) | ||
>K : Symbol(K, Decl(mod1.js, 4, 1)) | ||
>K : Symbol(K, Decl(mod1.js, 0, 0)) | ||
|
38 changes: 38 additions & 0 deletions
38
tests/baselines/reference/commonJSImportClassTypeReference.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
=== tests/cases/conformance/salsa/main.js === | ||
const { K } = require("./mod1"); | ||
>K : typeof K | ||
>require("./mod1") : typeof import("tests/cases/conformance/salsa/mod1") | ||
>require : any | ||
>"./mod1" : "./mod1" | ||
|
||
/** @param {K} k */ | ||
function f(k) { | ||
>f : (k: K) => void | ||
>k : K | ||
|
||
k.values() | ||
>k.values() : K | ||
>k.values : () => K | ||
>k : K | ||
>values : () => K | ||
} | ||
|
||
=== tests/cases/conformance/salsa/mod1.js === | ||
class K { | ||
>K : K | ||
|
||
values() { | ||
>values : () => K | ||
|
||
return new K() | ||
>new K() : K | ||
>K : typeof K | ||
} | ||
} | ||
exports.K = K; | ||
>exports.K = K : typeof K | ||
>exports.K : typeof K | ||
>exports : typeof import("tests/cases/conformance/salsa/mod1") | ||
>K : typeof K | ||
>K : typeof K | ||
|
48 changes: 48 additions & 0 deletions
48
tests/baselines/reference/commonJSImportNestedClassTypeReference.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//// [tests/cases/conformance/salsa/commonJSImportNestedClassTypeReference.ts] //// | ||
|
||
//// [main.js] | ||
const { K } = require("./mod1"); | ||
/** @param {K} k */ | ||
function f(k) { | ||
k.values() | ||
} | ||
|
||
//// [mod1.js] | ||
var NS = {} | ||
NS.K =class { | ||
values() { | ||
return new NS.K() | ||
} | ||
} | ||
exports.K = NS.K; | ||
|
||
|
||
//// [mod1.js] | ||
"use strict"; | ||
var NS = {}; | ||
NS.K = /** @class */ (function () { | ||
function K() { | ||
} | ||
K.prototype.values = function () { | ||
return new NS.K(); | ||
}; | ||
return K; | ||
}()); | ||
exports.K = NS.K; | ||
//// [main.js] | ||
"use strict"; | ||
var K = require("./mod1").K; | ||
/** @param {K} k */ | ||
function f(k) { | ||
k.values(); | ||
} | ||
|
||
|
||
//// [mod1.d.ts] | ||
export var K: { | ||
new (): { | ||
values(): any; | ||
}; | ||
}; | ||
//// [main.d.ts] | ||
export {}; |
43 changes: 43 additions & 0 deletions
43
tests/baselines/reference/commonJSImportNestedClassTypeReference.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
=== tests/cases/conformance/salsa/main.js === | ||
const { K } = require("./mod1"); | ||
>K : Symbol(K, Decl(main.js, 0, 7)) | ||
>require : Symbol(require) | ||
>"./mod1" : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) | ||
|
||
/** @param {K} k */ | ||
function f(k) { | ||
>f : Symbol(f, Decl(main.js, 0, 32)) | ||
>k : Symbol(k, Decl(main.js, 2, 11)) | ||
|
||
k.values() | ||
>k.values : Symbol(K.values, Decl(mod1.js, 1, 13)) | ||
>k : Symbol(k, Decl(main.js, 2, 11)) | ||
>values : Symbol(K.values, Decl(mod1.js, 1, 13)) | ||
} | ||
|
||
=== tests/cases/conformance/salsa/mod1.js === | ||
var NS = {} | ||
>NS : Symbol(NS, Decl(mod1.js, 0, 3), Decl(mod1.js, 0, 11)) | ||
|
||
NS.K =class { | ||
>NS.K : Symbol(K, Decl(mod1.js, 0, 11)) | ||
>NS : Symbol(NS, Decl(mod1.js, 0, 3), Decl(mod1.js, 0, 11)) | ||
>K : Symbol(K, Decl(mod1.js, 0, 11)) | ||
|
||
values() { | ||
>values : Symbol(K.values, Decl(mod1.js, 1, 13)) | ||
|
||
return new NS.K() | ||
>NS.K : Symbol(K, Decl(mod1.js, 0, 11)) | ||
>NS : Symbol(NS, Decl(mod1.js, 0, 3), Decl(mod1.js, 0, 11)) | ||
>K : Symbol(K, Decl(mod1.js, 0, 11)) | ||
} | ||
} | ||
exports.K = NS.K; | ||
>exports.K : Symbol(K, Decl(mod1.js, 5, 1)) | ||
>exports : Symbol(K, Decl(mod1.js, 5, 1)) | ||
>K : Symbol(K, Decl(mod1.js, 5, 1)) | ||
>NS.K : Symbol(K, Decl(mod1.js, 0, 11)) | ||
>NS : Symbol(NS, Decl(mod1.js, 0, 3), Decl(mod1.js, 0, 11)) | ||
>K : Symbol(K, Decl(mod1.js, 0, 11)) | ||
|
50 changes: 50 additions & 0 deletions
50
tests/baselines/reference/commonJSImportNestedClassTypeReference.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
=== tests/cases/conformance/salsa/main.js === | ||
const { K } = require("./mod1"); | ||
>K : typeof K | ||
>require("./mod1") : typeof import("tests/cases/conformance/salsa/mod1") | ||
>require : any | ||
>"./mod1" : "./mod1" | ||
|
||
/** @param {K} k */ | ||
function f(k) { | ||
>f : (k: K) => void | ||
>k : K | ||
|
||
k.values() | ||
>k.values() : K | ||
>k.values : () => K | ||
>k : K | ||
>values : () => K | ||
} | ||
|
||
=== tests/cases/conformance/salsa/mod1.js === | ||
var NS = {} | ||
>NS : typeof NS | ||
>{} : {} | ||
|
||
NS.K =class { | ||
>NS.K =class { values() { return new NS.K() }} : typeof K | ||
>NS.K : typeof K | ||
>NS : typeof NS | ||
>K : typeof K | ||
>class { values() { return new NS.K() }} : typeof K | ||
|
||
values() { | ||
>values : () => K | ||
|
||
return new NS.K() | ||
>new NS.K() : K | ||
>NS.K : typeof K | ||
>NS : typeof NS | ||
>K : typeof K | ||
} | ||
} | ||
exports.K = NS.K; | ||
>exports.K = NS.K : typeof K | ||
>exports.K : typeof K | ||
>exports : typeof import("tests/cases/conformance/salsa/mod1") | ||
>K : typeof K | ||
>NS.K : typeof K | ||
>NS : typeof NS | ||
>K : typeof K | ||
|
Oops, something went wrong.