-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fix emit for export {...}
with ES6 target and non-ES6 modules
#5176
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 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 hidden or 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 hidden or 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,73 @@ | ||
//// [tests/cases/conformance/es6/modules/exportsAndImports1-es6.ts] //// | ||
|
||
//// [t1.ts] | ||
|
||
var v = 1; | ||
function f() { } | ||
class C { | ||
} | ||
interface I { | ||
} | ||
enum E { | ||
A, B, C | ||
} | ||
const enum D { | ||
A, B, C | ||
} | ||
module M { | ||
export var x; | ||
} | ||
module N { | ||
export interface I { | ||
} | ||
} | ||
type T = number; | ||
import a = M.x; | ||
|
||
export { v, f, C, I, E, D, M, N, T, a }; | ||
|
||
//// [t2.ts] | ||
export { v, f, C, I, E, D, M, N, T, a } from "./t1"; | ||
|
||
//// [t3.ts] | ||
import { v, f, C, I, E, D, M, N, T, a } from "./t1"; | ||
export { v, f, C, I, E, D, M, N, T, a }; | ||
|
||
|
||
//// [t1.js] | ||
var v = 1; | ||
exports.v = v; | ||
function f() { } | ||
exports.f = f; | ||
class C { | ||
} | ||
exports.C = C; | ||
var E; | ||
(function (E) { | ||
E[E["A"] = 0] = "A"; | ||
E[E["B"] = 1] = "B"; | ||
E[E["C"] = 2] = "C"; | ||
})(E || (E = {})); | ||
exports.E = E; | ||
var M; | ||
(function (M) { | ||
})(M || (M = {})); | ||
exports.M = M; | ||
var a = M.x; | ||
exports.a = a; | ||
//// [t2.js] | ||
var t1_1 = require("./t1"); | ||
exports.v = t1_1.v; | ||
exports.f = t1_1.f; | ||
exports.C = t1_1.C; | ||
exports.E = t1_1.E; | ||
exports.M = t1_1.M; | ||
exports.a = t1_1.a; | ||
//// [t3.js] | ||
var t1_1 = require("./t1"); | ||
exports.v = t1_1.v; | ||
exports.f = t1_1.f; | ||
exports.C = t1_1.C; | ||
exports.E = t1_1.E; | ||
exports.M = t1_1.M; | ||
exports.a = t1_1.a; |
101 changes: 101 additions & 0 deletions
101
tests/baselines/reference/exportsAndImports1-es6.symbols
This file contains hidden or 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,101 @@ | ||
=== tests/cases/conformance/es6/modules/t1.ts === | ||
|
||
var v = 1; | ||
>v : Symbol(v, Decl(t1.ts, 1, 3)) | ||
|
||
function f() { } | ||
>f : Symbol(f, Decl(t1.ts, 1, 10)) | ||
|
||
class C { | ||
>C : Symbol(C, Decl(t1.ts, 2, 16)) | ||
} | ||
interface I { | ||
>I : Symbol(I, Decl(t1.ts, 4, 1)) | ||
} | ||
enum E { | ||
>E : Symbol(E, Decl(t1.ts, 6, 1)) | ||
|
||
A, B, C | ||
>A : Symbol(E.A, Decl(t1.ts, 7, 8)) | ||
>B : Symbol(E.B, Decl(t1.ts, 8, 6)) | ||
>C : Symbol(E.C, Decl(t1.ts, 8, 9)) | ||
} | ||
const enum D { | ||
>D : Symbol(D, Decl(t1.ts, 9, 1)) | ||
|
||
A, B, C | ||
>A : Symbol(D.A, Decl(t1.ts, 10, 14)) | ||
>B : Symbol(D.B, Decl(t1.ts, 11, 6)) | ||
>C : Symbol(D.C, Decl(t1.ts, 11, 9)) | ||
} | ||
module M { | ||
>M : Symbol(M, Decl(t1.ts, 12, 1)) | ||
|
||
export var x; | ||
>x : Symbol(x, Decl(t1.ts, 14, 14)) | ||
} | ||
module N { | ||
>N : Symbol(N, Decl(t1.ts, 15, 1)) | ||
|
||
export interface I { | ||
>I : Symbol(I, Decl(t1.ts, 16, 10)) | ||
} | ||
} | ||
type T = number; | ||
>T : Symbol(T, Decl(t1.ts, 19, 1)) | ||
|
||
import a = M.x; | ||
>a : Symbol(a, Decl(t1.ts, 20, 16)) | ||
>M : Symbol(M, Decl(t1.ts, 12, 1)) | ||
>x : Symbol(a, Decl(t1.ts, 14, 14)) | ||
|
||
export { v, f, C, I, E, D, M, N, T, a }; | ||
>v : Symbol(v, Decl(t1.ts, 23, 8)) | ||
>f : Symbol(f, Decl(t1.ts, 23, 11)) | ||
>C : Symbol(C, Decl(t1.ts, 23, 14)) | ||
>I : Symbol(I, Decl(t1.ts, 23, 17)) | ||
>E : Symbol(E, Decl(t1.ts, 23, 20)) | ||
>D : Symbol(D, Decl(t1.ts, 23, 23)) | ||
>M : Symbol(M, Decl(t1.ts, 23, 26)) | ||
>N : Symbol(N, Decl(t1.ts, 23, 29)) | ||
>T : Symbol(T, Decl(t1.ts, 23, 32)) | ||
>a : Symbol(a, Decl(t1.ts, 23, 35)) | ||
|
||
=== tests/cases/conformance/es6/modules/t2.ts === | ||
export { v, f, C, I, E, D, M, N, T, a } from "./t1"; | ||
>v : Symbol(v, Decl(t2.ts, 0, 8)) | ||
>f : Symbol(f, Decl(t2.ts, 0, 11)) | ||
>C : Symbol(C, Decl(t2.ts, 0, 14)) | ||
>I : Symbol(I, Decl(t2.ts, 0, 17)) | ||
>E : Symbol(E, Decl(t2.ts, 0, 20)) | ||
>D : Symbol(D, Decl(t2.ts, 0, 23)) | ||
>M : Symbol(M, Decl(t2.ts, 0, 26)) | ||
>N : Symbol(N, Decl(t2.ts, 0, 29)) | ||
>T : Symbol(T, Decl(t2.ts, 0, 32)) | ||
>a : Symbol(a, Decl(t2.ts, 0, 35)) | ||
|
||
=== tests/cases/conformance/es6/modules/t3.ts === | ||
import { v, f, C, I, E, D, M, N, T, a } from "./t1"; | ||
>v : Symbol(v, Decl(t3.ts, 0, 8)) | ||
>f : Symbol(f, Decl(t3.ts, 0, 11)) | ||
>C : Symbol(C, Decl(t3.ts, 0, 14)) | ||
>I : Symbol(I, Decl(t3.ts, 0, 17)) | ||
>E : Symbol(E, Decl(t3.ts, 0, 20)) | ||
>D : Symbol(D, Decl(t3.ts, 0, 23)) | ||
>M : Symbol(M, Decl(t3.ts, 0, 26)) | ||
>N : Symbol(N, Decl(t3.ts, 0, 29)) | ||
>T : Symbol(T, Decl(t3.ts, 0, 32)) | ||
>a : Symbol(a, Decl(t3.ts, 0, 35)) | ||
|
||
export { v, f, C, I, E, D, M, N, T, a }; | ||
>v : Symbol(v, Decl(t3.ts, 1, 8)) | ||
>f : Symbol(f, Decl(t3.ts, 1, 11)) | ||
>C : Symbol(C, Decl(t3.ts, 1, 14)) | ||
>I : Symbol(I, Decl(t3.ts, 1, 17)) | ||
>E : Symbol(E, Decl(t3.ts, 1, 20)) | ||
>D : Symbol(D, Decl(t3.ts, 1, 23)) | ||
>M : Symbol(M, Decl(t3.ts, 1, 26)) | ||
>N : Symbol(N, Decl(t3.ts, 1, 29)) | ||
>T : Symbol(T, Decl(t3.ts, 1, 32)) | ||
>a : Symbol(a, Decl(t3.ts, 1, 35)) | ||
|
This file contains hidden or 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,102 @@ | ||
=== tests/cases/conformance/es6/modules/t1.ts === | ||
|
||
var v = 1; | ||
>v : number | ||
>1 : number | ||
|
||
function f() { } | ||
>f : () => void | ||
|
||
class C { | ||
>C : C | ||
} | ||
interface I { | ||
>I : I | ||
} | ||
enum E { | ||
>E : E | ||
|
||
A, B, C | ||
>A : E | ||
>B : E | ||
>C : E | ||
} | ||
const enum D { | ||
>D : D | ||
|
||
A, B, C | ||
>A : D | ||
>B : D | ||
>C : D | ||
} | ||
module M { | ||
>M : typeof M | ||
|
||
export var x; | ||
>x : any | ||
} | ||
module N { | ||
>N : any | ||
|
||
export interface I { | ||
>I : I | ||
} | ||
} | ||
type T = number; | ||
>T : number | ||
|
||
import a = M.x; | ||
>a : any | ||
>M : typeof M | ||
>x : any | ||
|
||
export { v, f, C, I, E, D, M, N, T, a }; | ||
>v : number | ||
>f : () => void | ||
>C : typeof C | ||
>I : any | ||
>E : typeof E | ||
>D : typeof D | ||
>M : typeof M | ||
>N : any | ||
>T : any | ||
>a : any | ||
|
||
=== tests/cases/conformance/es6/modules/t2.ts === | ||
export { v, f, C, I, E, D, M, N, T, a } from "./t1"; | ||
>v : number | ||
>f : () => void | ||
>C : typeof C | ||
>I : any | ||
>E : typeof E | ||
>D : typeof D | ||
>M : typeof M | ||
>N : any | ||
>T : any | ||
>a : any | ||
|
||
=== tests/cases/conformance/es6/modules/t3.ts === | ||
import { v, f, C, I, E, D, M, N, T, a } from "./t1"; | ||
>v : number | ||
>f : () => void | ||
>C : typeof C | ||
>I : any | ||
>E : typeof E | ||
>D : typeof D | ||
>M : typeof M | ||
>N : any | ||
>T : any | ||
>a : any | ||
|
||
export { v, f, C, I, E, D, M, N, T, a }; | ||
>v : number | ||
>f : () => void | ||
>C : typeof C | ||
>I : any | ||
>E : typeof E | ||
>D : typeof D | ||
>M : typeof M | ||
>N : any | ||
>T : any | ||
>a : any | ||
|
This file contains hidden or 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,26 @@ | ||
//// [tests/cases/conformance/es6/modules/exportsAndImports2-es6.ts] //// | ||
|
||
//// [t1.ts] | ||
|
||
export var x = "x"; | ||
export var y = "y"; | ||
|
||
//// [t2.ts] | ||
export { x as y, y as x } from "./t1"; | ||
|
||
//// [t3.ts] | ||
import { x, y } from "./t1"; | ||
export { x as y, y as x }; | ||
|
||
|
||
//// [t1.js] | ||
exports.x = "x"; | ||
exports.y = "y"; | ||
//// [t2.js] | ||
var t1_1 = require("./t1"); | ||
exports.y = t1_1.x; | ||
exports.x = t1_1.y; | ||
//// [t3.js] | ||
var t1_1 = require("./t1"); | ||
exports.y = t1_1.x; | ||
exports.x = t1_1.y; |
This file contains hidden or 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,26 @@ | ||
=== tests/cases/conformance/es6/modules/t1.ts === | ||
|
||
export var x = "x"; | ||
>x : Symbol(x, Decl(t1.ts, 1, 10)) | ||
|
||
export var y = "y"; | ||
>y : Symbol(y, Decl(t1.ts, 2, 10)) | ||
|
||
=== tests/cases/conformance/es6/modules/t2.ts === | ||
export { x as y, y as x } from "./t1"; | ||
>x : Symbol(y, Decl(t2.ts, 0, 8)) | ||
>y : Symbol(y, Decl(t2.ts, 0, 8)) | ||
>y : Symbol(x, Decl(t2.ts, 0, 16)) | ||
>x : Symbol(x, Decl(t2.ts, 0, 16)) | ||
|
||
=== tests/cases/conformance/es6/modules/t3.ts === | ||
import { x, y } from "./t1"; | ||
>x : Symbol(x, Decl(t3.ts, 0, 8)) | ||
>y : Symbol(y, Decl(t3.ts, 0, 11)) | ||
|
||
export { x as y, y as x }; | ||
>x : Symbol(y, Decl(t3.ts, 1, 8)) | ||
>y : Symbol(y, Decl(t3.ts, 1, 8)) | ||
>y : Symbol(x, Decl(t3.ts, 1, 16)) | ||
>x : Symbol(x, Decl(t3.ts, 1, 16)) | ||
|
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.
Add in a reassignment to
v
(ie,v = 10
) here. Observe that we emitv = 10
but no correspondingexports.v = v
. I'm not sure lifting all the exports from where the export statement is to wherever the variable's declaration is is correct for this export form.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.
That's an orthogonal issue already being discussed in #4101.
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.
Ahh, okay, didn't know about the old issue.