-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Add command line flag to allow synthetic default exports #5577
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
+435
−3
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a32f44f
Add command line flag to allow synthetic default exports
weswigham 9024032
use typeof
weswigham f28958f
Merge branch 'master' into autohoist-default
weswigham adc3f2b
update description
weswigham d74ab2e
Merge branch 'master' into autohoist-default
weswigham fd5f440
accept new baselines
weswigham 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
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
22 changes: 22 additions & 0 deletions
22
tests/baselines/reference/allowSyntheticDefaultImports1.js
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,22 @@ | ||
//// [tests/cases/compiler/allowSyntheticDefaultImports1.ts] //// | ||
|
||
//// [a.ts] | ||
import Namespace from "./b"; | ||
export var x = new Namespace.Foo(); | ||
|
||
//// [b.ts] | ||
export class Foo { | ||
member: string; | ||
} | ||
|
||
|
||
//// [b.js] | ||
var Foo = (function () { | ||
function Foo() { | ||
} | ||
return Foo; | ||
})(); | ||
exports.Foo = Foo; | ||
//// [a.js] | ||
var b_1 = require("./b"); | ||
exports.x = new b_1["default"].Foo(); |
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/allowSyntheticDefaultImports1.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,18 @@ | ||
=== tests/cases/compiler/a.ts === | ||
import Namespace from "./b"; | ||
>Namespace : Symbol(Namespace, Decl(a.ts, 0, 6)) | ||
|
||
export var x = new Namespace.Foo(); | ||
>x : Symbol(x, Decl(a.ts, 1, 10)) | ||
>Namespace.Foo : Symbol(Namespace.Foo, Decl(b.ts, 0, 0)) | ||
>Namespace : Symbol(Namespace, Decl(a.ts, 0, 6)) | ||
>Foo : Symbol(Namespace.Foo, Decl(b.ts, 0, 0)) | ||
|
||
=== tests/cases/compiler/b.ts === | ||
export class Foo { | ||
>Foo : Symbol(Foo, Decl(b.ts, 0, 0)) | ||
|
||
member: string; | ||
>member : Symbol(member, Decl(b.ts, 0, 18)) | ||
} | ||
|
19 changes: 19 additions & 0 deletions
19
tests/baselines/reference/allowSyntheticDefaultImports1.types
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,19 @@ | ||
=== tests/cases/compiler/a.ts === | ||
import Namespace from "./b"; | ||
>Namespace : typeof Namespace | ||
|
||
export var x = new Namespace.Foo(); | ||
>x : Namespace.Foo | ||
>new Namespace.Foo() : Namespace.Foo | ||
>Namespace.Foo : typeof Namespace.Foo | ||
>Namespace : typeof Namespace | ||
>Foo : typeof Namespace.Foo | ||
|
||
=== tests/cases/compiler/b.ts === | ||
export class Foo { | ||
>Foo : Foo | ||
|
||
member: string; | ||
>member : string | ||
} | ||
|
40 changes: 40 additions & 0 deletions
40
tests/baselines/reference/allowSyntheticDefaultImports2.js
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,40 @@ | ||
//// [tests/cases/compiler/allowSyntheticDefaultImports2.ts] //// | ||
|
||
//// [a.ts] | ||
import Namespace from "./b"; | ||
export var x = new Namespace.Foo(); | ||
|
||
//// [b.ts] | ||
export class Foo { | ||
member: string; | ||
} | ||
|
||
//// [b.js] | ||
System.register([], function(exports_1) { | ||
var Foo; | ||
return { | ||
setters:[], | ||
execute: function() { | ||
Foo = (function () { | ||
function Foo() { | ||
} | ||
return Foo; | ||
})(); | ||
exports_1("Foo", Foo); | ||
} | ||
} | ||
}); | ||
//// [a.js] | ||
System.register(["./b"], function(exports_1) { | ||
var b_1; | ||
var x; | ||
return { | ||
setters:[ | ||
function (b_1_1) { | ||
b_1 = b_1_1; | ||
}], | ||
execute: function() { | ||
exports_1("x", x = new b_1["default"].Foo()); | ||
} | ||
} | ||
}); |
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/allowSyntheticDefaultImports2.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,17 @@ | ||
=== tests/cases/compiler/a.ts === | ||
import Namespace from "./b"; | ||
>Namespace : Symbol(Namespace, Decl(a.ts, 0, 6)) | ||
|
||
export var x = new Namespace.Foo(); | ||
>x : Symbol(x, Decl(a.ts, 1, 10)) | ||
>Namespace.Foo : Symbol(Namespace.Foo, Decl(b.ts, 0, 0)) | ||
>Namespace : Symbol(Namespace, Decl(a.ts, 0, 6)) | ||
>Foo : Symbol(Namespace.Foo, Decl(b.ts, 0, 0)) | ||
|
||
=== tests/cases/compiler/b.ts === | ||
export class Foo { | ||
>Foo : Symbol(Foo, Decl(b.ts, 0, 0)) | ||
|
||
member: string; | ||
>member : Symbol(member, Decl(b.ts, 0, 18)) | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/allowSyntheticDefaultImports2.types
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,18 @@ | ||
=== tests/cases/compiler/a.ts === | ||
import Namespace from "./b"; | ||
>Namespace : typeof Namespace | ||
|
||
export var x = new Namespace.Foo(); | ||
>x : Namespace.Foo | ||
>new Namespace.Foo() : Namespace.Foo | ||
>Namespace.Foo : typeof Namespace.Foo | ||
>Namespace : typeof Namespace | ||
>Foo : typeof Namespace.Foo | ||
|
||
=== tests/cases/compiler/b.ts === | ||
export class Foo { | ||
>Foo : Foo | ||
|
||
member: string; | ||
>member : string | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/baselines/reference/allowSyntheticDefaultImports3.errors.txt
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,14 @@ | ||
tests/cases/compiler/a.ts(1,8): error TS1192: Module '"tests/cases/compiler/b"' has no default export. | ||
|
||
|
||
==== tests/cases/compiler/a.ts (1 errors) ==== | ||
import Namespace from "./b"; | ||
~~~~~~~~~ | ||
!!! error TS1192: Module '"tests/cases/compiler/b"' has no default export. | ||
export var x = new Namespace.Foo(); | ||
|
||
==== tests/cases/compiler/b.ts (0 errors) ==== | ||
export class Foo { | ||
member: string; | ||
} | ||
|
41 changes: 41 additions & 0 deletions
41
tests/baselines/reference/allowSyntheticDefaultImports3.js
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,41 @@ | ||
//// [tests/cases/compiler/allowSyntheticDefaultImports3.ts] //// | ||
|
||
//// [a.ts] | ||
import Namespace from "./b"; | ||
export var x = new Namespace.Foo(); | ||
|
||
//// [b.ts] | ||
export class Foo { | ||
member: string; | ||
} | ||
|
||
|
||
//// [b.js] | ||
System.register([], function(exports_1) { | ||
var Foo; | ||
return { | ||
setters:[], | ||
execute: function() { | ||
Foo = (function () { | ||
function Foo() { | ||
} | ||
return Foo; | ||
})(); | ||
exports_1("Foo", Foo); | ||
} | ||
} | ||
}); | ||
//// [a.js] | ||
System.register(["./b"], function(exports_1) { | ||
var b_1; | ||
var x; | ||
return { | ||
setters:[ | ||
function (b_1_1) { | ||
b_1 = b_1_1; | ||
}], | ||
execute: function() { | ||
exports_1("x", x = new b_1["default"].Foo()); | ||
} | ||
} | ||
}); |
16 changes: 16 additions & 0 deletions
16
tests/baselines/reference/allowSyntheticDefaultImports4.js
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,16 @@ | ||
//// [tests/cases/compiler/allowSyntheticDefaultImports4.ts] //// | ||
|
||
//// [b.d.ts] | ||
declare class Foo { | ||
member: string; | ||
} | ||
export = Foo; | ||
|
||
//// [a.ts] | ||
import Foo from "./b"; | ||
export var x = new Foo(); | ||
|
||
|
||
//// [a.js] | ||
var b_1 = require("./b"); | ||
exports.x = new b_1["default"](); |
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/allowSyntheticDefaultImports4.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,18 @@ | ||
=== tests/cases/compiler/b.d.ts === | ||
declare class Foo { | ||
>Foo : Symbol(Foo, Decl(b.d.ts, 0, 0)) | ||
|
||
member: string; | ||
>member : Symbol(member, Decl(b.d.ts, 0, 19)) | ||
} | ||
export = Foo; | ||
>Foo : Symbol(Foo, Decl(b.d.ts, 0, 0)) | ||
|
||
=== tests/cases/compiler/a.ts === | ||
import Foo from "./b"; | ||
>Foo : Symbol(Foo, Decl(a.ts, 0, 6)) | ||
|
||
export var x = new Foo(); | ||
>x : Symbol(x, Decl(a.ts, 1, 10)) | ||
>Foo : Symbol(Foo, Decl(a.ts, 0, 6)) | ||
|
19 changes: 19 additions & 0 deletions
19
tests/baselines/reference/allowSyntheticDefaultImports4.types
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,19 @@ | ||
=== tests/cases/compiler/b.d.ts === | ||
declare class Foo { | ||
>Foo : Foo | ||
|
||
member: string; | ||
>member : string | ||
} | ||
export = Foo; | ||
>Foo : Foo | ||
|
||
=== tests/cases/compiler/a.ts === | ||
import Foo from "./b"; | ||
>Foo : typeof Foo | ||
|
||
export var x = new Foo(); | ||
>x : Foo | ||
>new Foo() : Foo | ||
>Foo : typeof Foo | ||
|
27 changes: 27 additions & 0 deletions
27
tests/baselines/reference/allowSyntheticDefaultImports5.js
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,27 @@ | ||
//// [tests/cases/compiler/allowSyntheticDefaultImports5.ts] //// | ||
|
||
//// [b.d.ts] | ||
declare class Foo { | ||
member: string; | ||
} | ||
export = Foo; | ||
|
||
//// [a.ts] | ||
import Foo from "./b"; | ||
export var x = new Foo(); | ||
|
||
|
||
//// [a.js] | ||
System.register(["./b"], function(exports_1) { | ||
var b_1; | ||
var x; | ||
return { | ||
setters:[ | ||
function (b_1_1) { | ||
b_1 = b_1_1; | ||
}], | ||
execute: function() { | ||
exports_1("x", x = new b_1["default"]()); | ||
} | ||
} | ||
}); |
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/allowSyntheticDefaultImports5.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,18 @@ | ||
=== tests/cases/compiler/b.d.ts === | ||
declare class Foo { | ||
>Foo : Symbol(Foo, Decl(b.d.ts, 0, 0)) | ||
|
||
member: string; | ||
>member : Symbol(member, Decl(b.d.ts, 0, 19)) | ||
} | ||
export = Foo; | ||
>Foo : Symbol(Foo, Decl(b.d.ts, 0, 0)) | ||
|
||
=== tests/cases/compiler/a.ts === | ||
import Foo from "./b"; | ||
>Foo : Symbol(Foo, Decl(a.ts, 0, 6)) | ||
|
||
export var x = new Foo(); | ||
>x : Symbol(x, Decl(a.ts, 1, 10)) | ||
>Foo : Symbol(Foo, Decl(a.ts, 0, 6)) | ||
|
19 changes: 19 additions & 0 deletions
19
tests/baselines/reference/allowSyntheticDefaultImports5.types
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,19 @@ | ||
=== tests/cases/compiler/b.d.ts === | ||
declare class Foo { | ||
>Foo : Foo | ||
|
||
member: string; | ||
>member : string | ||
} | ||
export = Foo; | ||
>Foo : Foo | ||
|
||
=== tests/cases/compiler/a.ts === | ||
import Foo from "./b"; | ||
>Foo : typeof Foo | ||
|
||
export var x = new Foo(); | ||
>x : Foo | ||
>new Foo() : Foo | ||
>Foo : typeof Foo | ||
|
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.
do we need to add more description that we are not adding anything to the emitted code, but that it is just an illusion to match what the loader would do.