-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bdf98f5
commit 621eee7
Showing
20 changed files
with
353 additions
and
8 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
error TS2468: Cannot find global value 'Promise'. | ||
b.ts(1,1): error TS2712: A dynamic import call in ES5 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. | ||
b.ts(1,14): error TS2792: Cannot find module 'a'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? | ||
|
||
|
||
!!! error TS2468: Cannot find global value 'Promise'. | ||
==== a.ts (0 errors) ==== | ||
export function foo() { | ||
console.log("foo from a"); | ||
} | ||
|
||
==== b.ts (2 errors) ==== | ||
import.defer("a").then(ns => { | ||
~~~~~~~~~~~~~~~~~ | ||
!!! error TS2712: A dynamic import call in ES5 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. | ||
~~~ | ||
!!! error TS2792: Cannot find module 'a'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? | ||
ns.foo(); | ||
}); | ||
|
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,21 @@ | ||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] //// | ||
|
||
//// [a.ts] | ||
export function foo() { | ||
console.log("foo from a"); | ||
} | ||
|
||
//// [b.ts] | ||
import.defer("a").then(ns => { | ||
ns.foo(); | ||
}); | ||
|
||
|
||
//// [a.js] | ||
export function foo() { | ||
console.log("foo from a"); | ||
} | ||
//// [b.js] | ||
import.defer("a").then(function (ns) { | ||
ns.foo(); | ||
}); |
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,23 @@ | ||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] //// | ||
|
||
=== a.ts === | ||
export function foo() { | ||
>foo : Symbol(foo, Decl(a.ts, 0, 0)) | ||
|
||
console.log("foo from a"); | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
} | ||
|
||
=== b.ts === | ||
import.defer("a").then(ns => { | ||
>import.defer("a").then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) | ||
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) | ||
>ns : Symbol(ns, Decl(b.ts, 0, 23)) | ||
|
||
ns.foo(); | ||
>ns : Symbol(ns, Decl(b.ts, 0, 23)) | ||
|
||
}); | ||
|
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,53 @@ | ||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] //// | ||
|
||
=== a.ts === | ||
export function foo() { | ||
>foo : () => void | ||
> : ^^^^^^^^^^ | ||
|
||
console.log("foo from a"); | ||
>console.log("foo from a") : void | ||
> : ^^^^ | ||
>console.log : (...data: any[]) => void | ||
> : ^^^^ ^^ ^^^^^ | ||
>console : Console | ||
> : ^^^^^^^ | ||
>log : (...data: any[]) => void | ||
> : ^^^^ ^^ ^^^^^ | ||
>"foo from a" : "foo from a" | ||
> : ^^^^^^^^^^^^ | ||
} | ||
|
||
=== b.ts === | ||
import.defer("a").then(ns => { | ||
>import.defer("a").then(ns => { ns.foo();}) : Promise<void> | ||
> : ^^^^^^^^^^^^^ | ||
>import.defer("a").then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2> | ||
> : ^ ^^^^^^^^ ^^^^^^^^^^ ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
>import.defer("a") : Promise<any> | ||
> : ^^^^^^^^^^^^ | ||
>import.defer : any | ||
> : ^^^ | ||
>defer : any | ||
> : ^^^ | ||
>"a" : "a" | ||
> : ^^^ | ||
>then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2> | ||
> : ^ ^^^^^^^^ ^^^^^^^^^^ ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
>ns => { ns.foo();} : (ns: any) => void | ||
> : ^ ^^^^^^^^^^^^^^ | ||
>ns : any | ||
> : ^^^ | ||
|
||
ns.foo(); | ||
>ns.foo() : any | ||
> : ^^^ | ||
>ns.foo : any | ||
> : ^^^ | ||
>ns : any | ||
> : ^^^ | ||
>foo : any | ||
> : ^^^ | ||
|
||
}); | ||
|
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/dynamicImportDeferInvalidStandalone.errors.txt
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,18 @@ | ||
b.ts(1,1): error TS18061: 'import.defer' must be followed by '(' | ||
b.ts(3,2): error TS18061: 'import.defer' must be followed by '(' | ||
|
||
|
||
==== a.ts (0 errors) ==== | ||
export function foo() { | ||
console.log("foo from a"); | ||
} | ||
|
||
==== b.ts (2 errors) ==== | ||
import.defer; | ||
~~~~~~~~~~~~ | ||
!!! error TS18061: 'import.defer' must be followed by '(' | ||
|
||
(import.defer)("a"); | ||
~~~~~~~~~~~~ | ||
!!! error TS18061: 'import.defer' must be followed by '(' | ||
|
20 changes: 20 additions & 0 deletions
20
tests/baselines/reference/dynamicImportDeferInvalidStandalone.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,20 @@ | ||
//// [tests/cases/conformance/importDefer/dynamicImportDeferInvalidStandalone.ts] //// | ||
|
||
//// [a.ts] | ||
export function foo() { | ||
console.log("foo from a"); | ||
} | ||
|
||
//// [b.ts] | ||
import.defer; | ||
|
||
(import.defer)("a"); | ||
|
||
|
||
//// [a.js] | ||
export function foo() { | ||
console.log("foo from a"); | ||
} | ||
//// [b.js] | ||
import.defer; | ||
(import.defer)("a"); |
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/dynamicImportDeferInvalidStandalone.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,18 @@ | ||
//// [tests/cases/conformance/importDefer/dynamicImportDeferInvalidStandalone.ts] //// | ||
|
||
=== a.ts === | ||
export function foo() { | ||
>foo : Symbol(foo, Decl(a.ts, 0, 0)) | ||
|
||
console.log("foo from a"); | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
} | ||
|
||
=== b.ts === | ||
|
||
import.defer; | ||
|
||
(import.defer)("a"); | ||
|
39 changes: 39 additions & 0 deletions
39
tests/baselines/reference/dynamicImportDeferInvalidStandalone.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,39 @@ | ||
//// [tests/cases/conformance/importDefer/dynamicImportDeferInvalidStandalone.ts] //// | ||
|
||
=== a.ts === | ||
export function foo() { | ||
>foo : () => void | ||
> : ^^^^^^^^^^ | ||
|
||
console.log("foo from a"); | ||
>console.log("foo from a") : void | ||
> : ^^^^ | ||
>console.log : (...data: any[]) => void | ||
> : ^^^^ ^^ ^^^^^ | ||
>console : Console | ||
> : ^^^^^^^ | ||
>log : (...data: any[]) => void | ||
> : ^^^^ ^^ ^^^^^ | ||
>"foo from a" : "foo from a" | ||
> : ^^^^^^^^^^^^ | ||
} | ||
|
||
=== b.ts === | ||
import.defer; | ||
>import.defer : any | ||
> : ^^^ | ||
>defer : any | ||
> : ^^^ | ||
|
||
(import.defer)("a"); | ||
>(import.defer)("a") : any | ||
> : ^^^ | ||
>(import.defer) : any | ||
> : ^^^ | ||
>import.defer : any | ||
> : ^^^ | ||
>defer : any | ||
> : ^^^ | ||
>"a" : "a" | ||
> : ^^^ | ||
|
13 changes: 13 additions & 0 deletions
13
tests/baselines/reference/dynamicImportDeferMissingModuleESNext.errors.txt
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,13 @@ | ||
b.ts(1,1): error TS18060: Deferred imports are only supported when the '--module' flag is set to 'esnext'. | ||
b.ts(1,14): error TS2792: Cannot find module 'a'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? | ||
|
||
|
||
==== b.ts (2 errors) ==== | ||
import.defer("a").then(ns => { | ||
~~~~~~~~~~~~~~~~~ | ||
!!! error TS18060: Deferred imports are only supported when the '--module' flag is set to 'esnext'. | ||
~~~ | ||
!!! error TS2792: Cannot find module 'a'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? | ||
ns.foo(); | ||
}); | ||
|
12 changes: 12 additions & 0 deletions
12
tests/baselines/reference/dynamicImportDeferMissingModuleESNext.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,12 @@ | ||
//// [tests/cases/conformance/importDefer/dynamicImportDeferMissingModuleESNext.ts] //// | ||
|
||
//// [b.ts] | ||
import.defer("a").then(ns => { | ||
ns.foo(); | ||
}); | ||
|
||
|
||
//// [b.js] | ||
import.defer("a").then(ns => { | ||
ns.foo(); | ||
}); |
13 changes: 13 additions & 0 deletions
13
tests/baselines/reference/dynamicImportDeferMissingModuleESNext.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,13 @@ | ||
//// [tests/cases/conformance/importDefer/dynamicImportDeferMissingModuleESNext.ts] //// | ||
|
||
=== b.ts === | ||
import.defer("a").then(ns => { | ||
>import.defer("a").then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) | ||
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) | ||
>ns : Symbol(ns, Decl(b.ts, 0, 23)) | ||
|
||
ns.foo(); | ||
>ns : Symbol(ns, Decl(b.ts, 0, 23)) | ||
|
||
}); | ||
|
Oops, something went wrong.