-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alias for module.exports.x = x
#40228
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm - can we have an issue/update to get this to emit as
? That'd be more precise, and is reasonable enough given the (alias) symbol shape of the input, IMO. I imagine the serializer just isn't handling the NS nesting well right now, and it is falling back to a
var
-based emit, even though it all uses alias symbols.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#40479