From 0acd24489556589b660b9712e9c3a389ea3415ab Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Wed, 12 Jul 2017 11:42:21 -0700 Subject: [PATCH 1/4] Update tests --- .../importCallExpression4ESNext.ts | 1 + .../importCallExpressionES5AMD.ts | 6 +++++ .../importCallExpressionES5CJS.ts | 6 +++++ .../importCallExpressionES5System.ts | 6 +++++ .../importCallExpressionES5UMD.ts | 6 +++++ .../importCallExpressionES6AMD.ts | 27 +++++++++++++++++++ .../importCallExpressionES6CJS.ts | 27 +++++++++++++++++++ .../importCallExpressionES6System.ts | 27 +++++++++++++++++++ .../importCallExpressionES6UMD.ts | 27 +++++++++++++++++++ .../importCallExpressionInAMD4.ts | 15 +++++++++++ .../importCallExpressionInCJS5.ts | 15 +++++++++++ .../importCallExpressionInSystem4.ts | 15 +++++++++++ .../importCallExpressionInUMD4.ts | 15 +++++++++++ ...portCallExpressionNoModuleKindSpecified.ts | 1 + .../importCallExpressionWithTypeArgument.ts | 5 +--- 15 files changed, 195 insertions(+), 4 deletions(-) create mode 100644 tests/cases/conformance/dynamicImport/importCallExpressionES6AMD.ts create mode 100644 tests/cases/conformance/dynamicImport/importCallExpressionES6CJS.ts create mode 100644 tests/cases/conformance/dynamicImport/importCallExpressionES6System.ts create mode 100644 tests/cases/conformance/dynamicImport/importCallExpressionES6UMD.ts diff --git a/tests/cases/conformance/dynamicImport/importCallExpression4ESNext.ts b/tests/cases/conformance/dynamicImport/importCallExpression4ESNext.ts index 91342770d7d..7bc540e1e2a 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpression4ESNext.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpression4ESNext.ts @@ -15,6 +15,7 @@ declare var console: any; class C { private myModule = import("./0"); method() { + const loadAsync = import ("./0"); this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES5AMD.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES5AMD.ts index 33c31283ea0..5e96b21acfd 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionES5AMD.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES5AMD.ts @@ -13,4 +13,10 @@ p1.then(zero => { function foo() { const p2 = import("./0"); +} + +class C { + method() { + const loadAsync = import ("./0"); + } } \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES5CJS.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES5CJS.ts index 900ddbdba0c..925b60a28c5 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionES5CJS.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES5CJS.ts @@ -13,4 +13,10 @@ p1.then(zero => { function foo() { const p2 = import("./0"); +} + +class C { + method() { + const loadAsync = import ("./0"); + } } \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES5System.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES5System.ts index c00ab6899c6..de849af1f2a 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionES5System.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES5System.ts @@ -13,4 +13,10 @@ p1.then(zero => { function foo() { const p2 = import("./0"); +} + +class C { + method() { + const loadAsync = import ("./0"); + } } \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES5UMD.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES5UMD.ts index 699b0ffc342..6f6221dbeef 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionES5UMD.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES5UMD.ts @@ -13,4 +13,10 @@ p1.then(zero => { function foo() { const p2 = import("./0"); +} + +class C { + method() { + const loadAsync = import ("./0"); + } } \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES6AMD.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES6AMD.ts new file mode 100644 index 00000000000..2a4283acdaa --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES6AMD.ts @@ -0,0 +1,27 @@ +// @module: amd +// @target: es6 +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +import("./0"); +var p1 = import("./0"); +p1.then(zero => { + return zero.foo(); +}); + +function foo() { + const p2 = import("./0"); +} + +class C { + method() { + const loadAsync = import ("./0"); + } +} + +export class D { + method() { + const loadAsync = import ("./0"); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES6CJS.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES6CJS.ts new file mode 100644 index 00000000000..24bd52f9cf2 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES6CJS.ts @@ -0,0 +1,27 @@ +// @module: commonjs +// @target: es6 +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +import("./0"); +var p1 = import("./0"); +p1.then(zero => { + return zero.foo(); +}); + +function foo() { + const p2 = import("./0"); +} + +class C { + method() { + const loadAsync = import ("./0"); + } +} + +export class D { + method() { + const loadAsync = import ("./0"); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES6System.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES6System.ts new file mode 100644 index 00000000000..cea19d44a87 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES6System.ts @@ -0,0 +1,27 @@ +// @module: system +// @target: es6 +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +import("./0"); +var p1 = import("./0"); +p1.then(zero => { + return zero.foo(); +}); + +function foo() { + const p2 = import("./0"); +} + +class C { + method() { + const loadAsync = import ("./0"); + } +} + +export class D { + method() { + const loadAsync = import ("./0"); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES6UMD.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES6UMD.ts new file mode 100644 index 00000000000..01ab3c67c9c --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES6UMD.ts @@ -0,0 +1,27 @@ +// @module: umd +// @target: es6 +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +import("./0"); +var p1 = import("./0"); +p1.then(zero => { + return zero.foo(); +}); + +function foo() { + const p2 = import("./0"); +} + +class C { + method() { + const loadAsync = import ("./0"); + } +} + +export class D { + method() { + const loadAsync = import ("./0"); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInAMD4.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInAMD4.ts index 10044ab674c..ae861ff6987 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionInAMD4.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInAMD4.ts @@ -15,6 +15,21 @@ declare var console: any; class C { private myModule = import("./0"); method() { + const loadAsync = import("./0"); + this.myModule.then(Zero => { + console.log(Zero.foo()); + }, async err => { + console.log(err); + let one = await import("./1"); + console.log(one.backup()); + }); + } +} + +export class D { + private myModule = import("./0"); + method() { + const loadAsync = import("./0"); this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInCJS5.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInCJS5.ts index db86764802b..c7dfbc663d1 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionInCJS5.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInCJS5.ts @@ -15,6 +15,21 @@ declare var console: any; class C { private myModule = import("./0"); method() { + const loadAsync = import ("./0"); + this.myModule.then(Zero => { + console.log(Zero.foo()); + }, async err => { + console.log(err); + let one = await import("./1"); + console.log(one.backup()); + }); + } +} + +export class D { + private myModule = import("./0"); + method() { + const loadAsync = import("./0"); this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInSystem4.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInSystem4.ts index 1ab3040862c..d3f25ab1e35 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionInSystem4.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInSystem4.ts @@ -15,6 +15,21 @@ declare var console: any; class C { private myModule = import("./0"); method() { + const loadAsync = import("./0"); + this.myModule.then(Zero => { + console.log(Zero.foo()); + }, async err => { + console.log(err); + let one = await import("./1"); + console.log(one.backup()); + }); + } +} + +export class D { + private myModule = import("./0"); + method() { + const loadAsync = import("./0"); this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInUMD4.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInUMD4.ts index ef0f0999407..35750f30da8 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionInUMD4.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInUMD4.ts @@ -15,6 +15,21 @@ declare var console: any; class C { private myModule = import("./0"); method() { + const loadAsync = import("./0"); + this.myModule.then(Zero => { + console.log(Zero.foo()); + }, async err => { + console.log(err); + let one = await import("./1"); + console.log(one.backup()); + }); + } +} + +export class D { + private myModule = import("./0"); + method() { + const loadAsync = import("./0"); this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionNoModuleKindSpecified.ts b/tests/cases/conformance/dynamicImport/importCallExpressionNoModuleKindSpecified.ts index 2d2f54e00b1..856f763eb56 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionNoModuleKindSpecified.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionNoModuleKindSpecified.ts @@ -13,6 +13,7 @@ declare var console: any; class C { private myModule = import("./0"); method() { + const loadAsync = import("./0"); this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionWithTypeArgument.ts b/tests/cases/conformance/dynamicImport/importCallExpressionWithTypeArgument.ts index 895b61af6ff..09f07d9f9c0 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionWithTypeArgument.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionWithTypeArgument.ts @@ -8,7 +8,4 @@ export function foo() { return "foo"; } // @filename: 1.ts "use strict" var p1 = import>("./0"); // error -var p2 = import<>("./0"); // error -// p1.then(value => { -// value.anyFunction(); -// }) \ No newline at end of file +var p2 = import<>("./0"); // error \ No newline at end of file From 4ba3e109bd3c949b2567bdebe0655b90f4f36034 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Wed, 12 Jul 2017 13:01:22 -0700 Subject: [PATCH 2/4] Transform class member of export class declaration --- src/compiler/transformers/module/module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 1e73e3a4af6..aaff86c0c2e 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -924,7 +924,7 @@ namespace ts { getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, visitNodes(node.heritageClauses, importCallExpressionVisitor), - node.members + visitNodes(node.members, importCallExpressionVisitor) ), node ), From 2e6a1371d8a079174602a16d5b2c3cf69d99d979 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Wed, 12 Jul 2017 13:01:56 -0700 Subject: [PATCH 3/4] Add test for export variable statement --- .../dynamicImport/importCallExpression1ESNext.ts | 2 ++ .../dynamicImport/importCallExpressionES5AMD.ts | 8 ++++++++ .../dynamicImport/importCallExpressionES5CJS.ts | 8 ++++++++ .../dynamicImport/importCallExpressionES5System.ts | 8 ++++++++ .../dynamicImport/importCallExpressionES5UMD.ts | 8 ++++++++ .../dynamicImport/importCallExpressionES6AMD.ts | 2 ++ .../dynamicImport/importCallExpressionES6CJS.ts | 2 ++ .../dynamicImport/importCallExpressionES6System.ts | 2 ++ .../dynamicImport/importCallExpressionES6UMD.ts | 2 ++ .../dynamicImport/importCallExpressionInAMD1.ts | 2 ++ .../dynamicImport/importCallExpressionInCJS1.ts | 2 ++ .../dynamicImport/importCallExpressionInSystem1.ts | 2 ++ .../dynamicImport/importCallExpressionInUMD1.ts | 2 ++ 13 files changed, 50 insertions(+) diff --git a/tests/cases/conformance/dynamicImport/importCallExpression1ESNext.ts b/tests/cases/conformance/dynamicImport/importCallExpression1ESNext.ts index 295b6470301..a499360f5dd 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpression1ESNext.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpression1ESNext.ts @@ -10,6 +10,8 @@ p1.then(zero => { return zero.foo(); }) +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); } \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES5AMD.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES5AMD.ts index 5e96b21acfd..e218dd4758b 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionES5AMD.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES5AMD.ts @@ -11,6 +11,8 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); } @@ -19,4 +21,10 @@ class C { method() { const loadAsync = import ("./0"); } +} + +export class D { + method() { + const loadAsync = import ("./0"); + } } \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES5CJS.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES5CJS.ts index 925b60a28c5..2c45d42abbe 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionES5CJS.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES5CJS.ts @@ -11,6 +11,8 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); } @@ -19,4 +21,10 @@ class C { method() { const loadAsync = import ("./0"); } +} + +export class D { + method() { + const loadAsync = import ("./0"); + } } \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES5System.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES5System.ts index de849af1f2a..b9f8bac1920 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionES5System.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES5System.ts @@ -11,6 +11,8 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); } @@ -19,4 +21,10 @@ class C { method() { const loadAsync = import ("./0"); } +} + +export class D { + method() { + const loadAsync = import ("./0"); + } } \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES5UMD.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES5UMD.ts index 6f6221dbeef..66877c79ced 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionES5UMD.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES5UMD.ts @@ -11,6 +11,8 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); } @@ -19,4 +21,10 @@ class C { method() { const loadAsync = import ("./0"); } +} + +export class D { + method() { + const loadAsync = import ("./0"); + } } \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES6AMD.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES6AMD.ts index 2a4283acdaa..7e45b081ba4 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionES6AMD.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES6AMD.ts @@ -10,6 +10,8 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); } diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES6CJS.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES6CJS.ts index 24bd52f9cf2..0267c490712 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionES6CJS.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES6CJS.ts @@ -10,6 +10,8 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); } diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES6System.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES6System.ts index cea19d44a87..cf78470c30b 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionES6System.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES6System.ts @@ -10,6 +10,8 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); } diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES6UMD.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES6UMD.ts index 01ab3c67c9c..060b6097d3d 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionES6UMD.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES6UMD.ts @@ -10,6 +10,8 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); } diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInAMD1.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInAMD1.ts index 63cfc54c732..7aafc5294ff 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionInAMD1.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInAMD1.ts @@ -10,6 +10,8 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); } \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInCJS1.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInCJS1.ts index e1457017552..9827828a0a0 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionInCJS1.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInCJS1.ts @@ -10,6 +10,8 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); } \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInSystem1.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInSystem1.ts index a69e844c7a7..bbc265bc13f 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionInSystem1.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInSystem1.ts @@ -10,6 +10,8 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); } \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInUMD1.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInUMD1.ts index 05c4d699104..b273d1594b3 100644 --- a/tests/cases/conformance/dynamicImport/importCallExpressionInUMD1.ts +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInUMD1.ts @@ -10,6 +10,8 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); } \ No newline at end of file From 605bd1c4d6b2022b19239de08588fcdc3c33b82a Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Wed, 12 Jul 2017 13:02:08 -0700 Subject: [PATCH 4/4] Update baselines --- .../reference/importCallExpression1ESNext.js | 3 + .../importCallExpression1ESNext.symbols | 8 +- .../importCallExpression1ESNext.types | 5 ++ .../reference/importCallExpression4ESNext.js | 2 + .../importCallExpression4ESNext.symbols | 16 ++-- .../importCallExpression4ESNext.types | 5 ++ .../reference/importCallExpressionES5AMD.js | 35 +++++++- .../importCallExpressionES5AMD.symbols | 32 +++++++- .../importCallExpressionES5AMD.types | 31 ++++++++ .../reference/importCallExpressionES5CJS.js | 34 ++++++++ .../importCallExpressionES5CJS.symbols | 32 +++++++- .../importCallExpressionES5CJS.types | 31 ++++++++ .../importCallExpressionES5System.js | 35 +++++++- .../importCallExpressionES5System.symbols | 32 +++++++- .../importCallExpressionES5System.types | 31 ++++++++ .../reference/importCallExpressionES5UMD.js | 35 +++++++- .../importCallExpressionES5UMD.symbols | 32 +++++++- .../importCallExpressionES5UMD.types | 31 ++++++++ .../reference/importCallExpressionES6AMD.js | 62 +++++++++++++++ .../importCallExpressionES6AMD.symbols | 60 ++++++++++++++ .../importCallExpressionES6AMD.types | 70 ++++++++++++++++ .../reference/importCallExpressionES6CJS.js | 58 ++++++++++++++ .../importCallExpressionES6CJS.symbols | 60 ++++++++++++++ .../importCallExpressionES6CJS.types | 70 ++++++++++++++++ .../importCallExpressionES6System.js | 73 +++++++++++++++++ .../importCallExpressionES6System.symbols | 60 ++++++++++++++ .../importCallExpressionES6System.types | 70 ++++++++++++++++ .../reference/importCallExpressionES6UMD.js | 79 +++++++++++++++++++ .../importCallExpressionES6UMD.symbols | 60 ++++++++++++++ .../importCallExpressionES6UMD.types | 70 ++++++++++++++++ .../reference/importCallExpressionInAMD1.js | 6 +- .../importCallExpressionInAMD1.symbols | 8 +- .../importCallExpressionInAMD1.types | 5 ++ .../reference/importCallExpressionInAMD4.js | 35 +++++++- .../importCallExpressionInAMD4.symbols | 65 +++++++++++++-- .../importCallExpressionInAMD4.types | 72 +++++++++++++++++ .../reference/importCallExpressionInCJS1.js | 5 ++ .../importCallExpressionInCJS1.symbols | 8 +- .../importCallExpressionInCJS1.types | 5 ++ .../reference/importCallExpressionInCJS5.js | 34 ++++++++ .../importCallExpressionInCJS5.symbols | 65 +++++++++++++-- .../importCallExpressionInCJS5.types | 72 +++++++++++++++++ .../importCallExpressionInSystem1.js | 6 +- .../importCallExpressionInSystem1.symbols | 8 +- .../importCallExpressionInSystem1.types | 5 ++ .../importCallExpressionInSystem4.js | 35 +++++++- .../importCallExpressionInSystem4.symbols | 65 +++++++++++++-- .../importCallExpressionInSystem4.types | 72 +++++++++++++++++ .../reference/importCallExpressionInUMD1.js | 6 +- .../importCallExpressionInUMD1.symbols | 8 +- .../importCallExpressionInUMD1.types | 5 ++ .../reference/importCallExpressionInUMD4.js | 35 +++++++- .../importCallExpressionInUMD4.symbols | 65 +++++++++++++-- .../importCallExpressionInUMD4.types | 72 +++++++++++++++++ ...ExpressionNoModuleKindSpecified.errors.txt | 10 ++- ...portCallExpressionNoModuleKindSpecified.js | 2 + ...tCallExpressionWithTypeArgument.errors.txt | 5 +- .../importCallExpressionWithTypeArgument.js | 5 +- 58 files changed, 1938 insertions(+), 68 deletions(-) create mode 100644 tests/baselines/reference/importCallExpressionES6AMD.js create mode 100644 tests/baselines/reference/importCallExpressionES6AMD.symbols create mode 100644 tests/baselines/reference/importCallExpressionES6AMD.types create mode 100644 tests/baselines/reference/importCallExpressionES6CJS.js create mode 100644 tests/baselines/reference/importCallExpressionES6CJS.symbols create mode 100644 tests/baselines/reference/importCallExpressionES6CJS.types create mode 100644 tests/baselines/reference/importCallExpressionES6System.js create mode 100644 tests/baselines/reference/importCallExpressionES6System.symbols create mode 100644 tests/baselines/reference/importCallExpressionES6System.types create mode 100644 tests/baselines/reference/importCallExpressionES6UMD.js create mode 100644 tests/baselines/reference/importCallExpressionES6UMD.symbols create mode 100644 tests/baselines/reference/importCallExpressionES6UMD.types diff --git a/tests/baselines/reference/importCallExpression1ESNext.js b/tests/baselines/reference/importCallExpression1ESNext.js index 39b779c921f..32d45aaf628 100644 --- a/tests/baselines/reference/importCallExpression1ESNext.js +++ b/tests/baselines/reference/importCallExpression1ESNext.js @@ -10,6 +10,8 @@ p1.then(zero => { return zero.foo(); }) +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); } @@ -22,6 +24,7 @@ var p1 = import("./0"); p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); function foo() { const p2 = import("./0"); } diff --git a/tests/baselines/reference/importCallExpression1ESNext.symbols b/tests/baselines/reference/importCallExpression1ESNext.symbols index 564943aca54..33cf3c23420 100644 --- a/tests/baselines/reference/importCallExpression1ESNext.symbols +++ b/tests/baselines/reference/importCallExpression1ESNext.symbols @@ -23,10 +23,14 @@ p1.then(zero => { }) +export var p2 = import("./0"); +>p2 : Symbol(p2, Decl(1.ts, 6, 10)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + function foo() { ->foo : Symbol(foo, Decl(1.ts, 4, 2)) +>foo : Symbol(foo, Decl(1.ts, 6, 30)) const p2 = import("./0"); ->p2 : Symbol(p2, Decl(1.ts, 7, 9)) +>p2 : Symbol(p2, Decl(1.ts, 9, 9)) >"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) } diff --git a/tests/baselines/reference/importCallExpression1ESNext.types b/tests/baselines/reference/importCallExpression1ESNext.types index 53a1b3d08fa..29e2c3d261b 100644 --- a/tests/baselines/reference/importCallExpression1ESNext.types +++ b/tests/baselines/reference/importCallExpression1ESNext.types @@ -29,6 +29,11 @@ p1.then(zero => { }) +export var p2 = import("./0"); +>p2 : Promise +>import("./0") : Promise +>"./0" : "./0" + function foo() { >foo : () => void diff --git a/tests/baselines/reference/importCallExpression4ESNext.js b/tests/baselines/reference/importCallExpression4ESNext.js index e148d5c1e51..d5d4a51d69f 100644 --- a/tests/baselines/reference/importCallExpression4ESNext.js +++ b/tests/baselines/reference/importCallExpression4ESNext.js @@ -15,6 +15,7 @@ declare var console: any; class C { private myModule = import("./0"); method() { + const loadAsync = import ("./0"); this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { @@ -38,6 +39,7 @@ class C { this.myModule = import("./0"); } method() { + const loadAsync = import("./0"); this.myModule.then(Zero => { console.log(Zero.foo()); }, async (err) => { diff --git a/tests/baselines/reference/importCallExpression4ESNext.symbols b/tests/baselines/reference/importCallExpression4ESNext.symbols index b02646d5e3d..ef8d6e9c509 100644 --- a/tests/baselines/reference/importCallExpression4ESNext.symbols +++ b/tests/baselines/reference/importCallExpression4ESNext.symbols @@ -27,35 +27,39 @@ class C { method() { >method : Symbol(C.method, Decl(2.ts, 2, 37)) + const loadAsync = import ("./0"); +>loadAsync : Symbol(loadAsync, Decl(2.ts, 4, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + this.myModule.then(Zero => { >this.myModule.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >this.myModule : Symbol(C.myModule, Decl(2.ts, 1, 9)) >this : Symbol(C, Decl(2.ts, 0, 25)) >myModule : Symbol(C.myModule, Decl(2.ts, 1, 9)) >then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) ->Zero : Symbol(Zero, Decl(2.ts, 4, 27)) +>Zero : Symbol(Zero, Decl(2.ts, 5, 27)) console.log(Zero.foo()); >console : Symbol(console, Decl(2.ts, 0, 11)) >Zero.foo : Symbol(foo, Decl(0.ts, 2, 1)) ->Zero : Symbol(Zero, Decl(2.ts, 4, 27)) +>Zero : Symbol(Zero, Decl(2.ts, 5, 27)) >foo : Symbol(foo, Decl(0.ts, 2, 1)) }, async err => { ->err : Symbol(err, Decl(2.ts, 6, 16)) +>err : Symbol(err, Decl(2.ts, 7, 16)) console.log(err); >console : Symbol(console, Decl(2.ts, 0, 11)) ->err : Symbol(err, Decl(2.ts, 6, 16)) +>err : Symbol(err, Decl(2.ts, 7, 16)) let one = await import("./1"); ->one : Symbol(one, Decl(2.ts, 8, 15)) +>one : Symbol(one, Decl(2.ts, 9, 15)) >"./1" : Symbol("tests/cases/conformance/dynamicImport/1", Decl(1.ts, 0, 0)) console.log(one.backup()); >console : Symbol(console, Decl(2.ts, 0, 11)) >one.backup : Symbol(backup, Decl(1.ts, 0, 0)) ->one : Symbol(one, Decl(2.ts, 8, 15)) +>one : Symbol(one, Decl(2.ts, 9, 15)) >backup : Symbol(backup, Decl(1.ts, 0, 0)) }); diff --git a/tests/baselines/reference/importCallExpression4ESNext.types b/tests/baselines/reference/importCallExpression4ESNext.types index 2ea666ba672..74cc6ff8b28 100644 --- a/tests/baselines/reference/importCallExpression4ESNext.types +++ b/tests/baselines/reference/importCallExpression4ESNext.types @@ -31,6 +31,11 @@ class C { method() { >method : () => void + const loadAsync = import ("./0"); +>loadAsync : Promise +>import ("./0") : Promise +>"./0" : "./0" + this.myModule.then(Zero => { >this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise >this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise diff --git a/tests/baselines/reference/importCallExpressionES5AMD.js b/tests/baselines/reference/importCallExpressionES5AMD.js index cce61a5a3f9..8fa22d81dc9 100644 --- a/tests/baselines/reference/importCallExpressionES5AMD.js +++ b/tests/baselines/reference/importCallExpressionES5AMD.js @@ -10,8 +10,22 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); +} + +class C { + method() { + const loadAsync = import ("./0"); + } +} + +export class D { + method() { + const loadAsync = import ("./0"); + } } //// [0.js] @@ -24,12 +38,31 @@ define(["require", "exports"], function (require, exports) { //// [1.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); }); var p1 = new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); }); p1.then(function (zero) { return zero.foo(); }); + exports.p2 = new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }); function foo() { - var p2 = new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }); + var p2 = new Promise(function (resolve_4, reject_4) { require(["./0"], resolve_4, reject_4); }); } + var C = (function () { + function C() { + } + C.prototype.method = function () { + var loadAsync = new Promise(function (resolve_5, reject_5) { require(["./0"], resolve_5, reject_5); }); + }; + return C; + }()); + var D = (function () { + function D() { + } + D.prototype.method = function () { + var loadAsync = new Promise(function (resolve_6, reject_6) { require(["./0"], resolve_6, reject_6); }); + }; + return D; + }()); + exports.D = D; }); diff --git a/tests/baselines/reference/importCallExpressionES5AMD.symbols b/tests/baselines/reference/importCallExpressionES5AMD.symbols index a1a506e7005..2f8bd23758d 100644 --- a/tests/baselines/reference/importCallExpressionES5AMD.symbols +++ b/tests/baselines/reference/importCallExpressionES5AMD.symbols @@ -23,10 +23,38 @@ p1.then(zero => { }); +export var p2 = import("./0"); +>p2 : Symbol(p2, Decl(1.ts, 6, 10)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + function foo() { ->foo : Symbol(foo, Decl(1.ts, 4, 3)) +>foo : Symbol(foo, Decl(1.ts, 6, 30)) const p2 = import("./0"); ->p2 : Symbol(p2, Decl(1.ts, 7, 9)) +>p2 : Symbol(p2, Decl(1.ts, 9, 9)) >"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) } + +class C { +>C : Symbol(C, Decl(1.ts, 10, 1)) + + method() { +>method : Symbol(C.method, Decl(1.ts, 12, 9)) + + const loadAsync = import ("./0"); +>loadAsync : Symbol(loadAsync, Decl(1.ts, 14, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + } +} + +export class D { +>D : Symbol(D, Decl(1.ts, 16, 1)) + + method() { +>method : Symbol(D.method, Decl(1.ts, 18, 16)) + + const loadAsync = import ("./0"); +>loadAsync : Symbol(loadAsync, Decl(1.ts, 20, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + } +} diff --git a/tests/baselines/reference/importCallExpressionES5AMD.types b/tests/baselines/reference/importCallExpressionES5AMD.types index 59da055ee01..e97f722b14f 100644 --- a/tests/baselines/reference/importCallExpressionES5AMD.types +++ b/tests/baselines/reference/importCallExpressionES5AMD.types @@ -29,6 +29,11 @@ p1.then(zero => { }); +export var p2 = import("./0"); +>p2 : Promise +>import("./0") : Promise +>"./0" : "./0" + function foo() { >foo : () => void @@ -37,3 +42,29 @@ function foo() { >import("./0") : Promise >"./0" : "./0" } + +class C { +>C : C + + method() { +>method : () => void + + const loadAsync = import ("./0"); +>loadAsync : Promise +>import ("./0") : Promise +>"./0" : "./0" + } +} + +export class D { +>D : D + + method() { +>method : () => void + + const loadAsync = import ("./0"); +>loadAsync : Promise +>import ("./0") : Promise +>"./0" : "./0" + } +} diff --git a/tests/baselines/reference/importCallExpressionES5CJS.js b/tests/baselines/reference/importCallExpressionES5CJS.js index 11d1bf46319..2cf5d3157e2 100644 --- a/tests/baselines/reference/importCallExpressionES5CJS.js +++ b/tests/baselines/reference/importCallExpressionES5CJS.js @@ -10,8 +10,22 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); +} + +class C { + method() { + const loadAsync = import ("./0"); + } +} + +export class D { + method() { + const loadAsync = import ("./0"); + } } //// [0.js] @@ -20,11 +34,31 @@ Object.defineProperty(exports, "__esModule", { value: true }); function foo() { return "foo"; } exports.foo = foo; //// [1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); Promise.resolve().then(function () { return require("./0"); }); var p1 = Promise.resolve().then(function () { return require("./0"); }); p1.then(function (zero) { return zero.foo(); }); +exports.p2 = Promise.resolve().then(function () { return require("./0"); }); function foo() { var p2 = Promise.resolve().then(function () { return require("./0"); }); } +var C = (function () { + function C() { + } + C.prototype.method = function () { + var loadAsync = Promise.resolve().then(function () { return require("./0"); }); + }; + return C; +}()); +var D = (function () { + function D() { + } + D.prototype.method = function () { + var loadAsync = Promise.resolve().then(function () { return require("./0"); }); + }; + return D; +}()); +exports.D = D; diff --git a/tests/baselines/reference/importCallExpressionES5CJS.symbols b/tests/baselines/reference/importCallExpressionES5CJS.symbols index a1a506e7005..2f8bd23758d 100644 --- a/tests/baselines/reference/importCallExpressionES5CJS.symbols +++ b/tests/baselines/reference/importCallExpressionES5CJS.symbols @@ -23,10 +23,38 @@ p1.then(zero => { }); +export var p2 = import("./0"); +>p2 : Symbol(p2, Decl(1.ts, 6, 10)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + function foo() { ->foo : Symbol(foo, Decl(1.ts, 4, 3)) +>foo : Symbol(foo, Decl(1.ts, 6, 30)) const p2 = import("./0"); ->p2 : Symbol(p2, Decl(1.ts, 7, 9)) +>p2 : Symbol(p2, Decl(1.ts, 9, 9)) >"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) } + +class C { +>C : Symbol(C, Decl(1.ts, 10, 1)) + + method() { +>method : Symbol(C.method, Decl(1.ts, 12, 9)) + + const loadAsync = import ("./0"); +>loadAsync : Symbol(loadAsync, Decl(1.ts, 14, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + } +} + +export class D { +>D : Symbol(D, Decl(1.ts, 16, 1)) + + method() { +>method : Symbol(D.method, Decl(1.ts, 18, 16)) + + const loadAsync = import ("./0"); +>loadAsync : Symbol(loadAsync, Decl(1.ts, 20, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + } +} diff --git a/tests/baselines/reference/importCallExpressionES5CJS.types b/tests/baselines/reference/importCallExpressionES5CJS.types index 59da055ee01..e97f722b14f 100644 --- a/tests/baselines/reference/importCallExpressionES5CJS.types +++ b/tests/baselines/reference/importCallExpressionES5CJS.types @@ -29,6 +29,11 @@ p1.then(zero => { }); +export var p2 = import("./0"); +>p2 : Promise +>import("./0") : Promise +>"./0" : "./0" + function foo() { >foo : () => void @@ -37,3 +42,29 @@ function foo() { >import("./0") : Promise >"./0" : "./0" } + +class C { +>C : C + + method() { +>method : () => void + + const loadAsync = import ("./0"); +>loadAsync : Promise +>import ("./0") : Promise +>"./0" : "./0" + } +} + +export class D { +>D : D + + method() { +>method : () => void + + const loadAsync = import ("./0"); +>loadAsync : Promise +>import ("./0") : Promise +>"./0" : "./0" + } +} diff --git a/tests/baselines/reference/importCallExpressionES5System.js b/tests/baselines/reference/importCallExpressionES5System.js index 1842fc6e60a..3dabfce80c9 100644 --- a/tests/baselines/reference/importCallExpressionES5System.js +++ b/tests/baselines/reference/importCallExpressionES5System.js @@ -10,8 +10,22 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); +} + +class C { + method() { + const loadAsync = import ("./0"); + } +} + +export class D { + method() { + const loadAsync = import ("./0"); + } } //// [0.js] @@ -28,11 +42,12 @@ System.register([], function (exports_1, context_1) { }); //// [1.js] System.register([], function (exports_1, context_1) { + "use strict"; var __moduleName = context_1 && context_1.id; function foo() { var p2 = context_1.import("./0"); } - var p1; + var p1, p2, C, D; return { setters: [], execute: function () { @@ -41,6 +56,24 @@ System.register([], function (exports_1, context_1) { p1.then(function (zero) { return zero.foo(); }); + exports_1("p2", p2 = context_1.import("./0")); + C = (function () { + function C() { + } + C.prototype.method = function () { + var loadAsync = context_1.import("./0"); + }; + return C; + }()); + D = (function () { + function D() { + } + D.prototype.method = function () { + var loadAsync = context_1.import("./0"); + }; + return D; + }()); + exports_1("D", D); } }; }); diff --git a/tests/baselines/reference/importCallExpressionES5System.symbols b/tests/baselines/reference/importCallExpressionES5System.symbols index a1a506e7005..2f8bd23758d 100644 --- a/tests/baselines/reference/importCallExpressionES5System.symbols +++ b/tests/baselines/reference/importCallExpressionES5System.symbols @@ -23,10 +23,38 @@ p1.then(zero => { }); +export var p2 = import("./0"); +>p2 : Symbol(p2, Decl(1.ts, 6, 10)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + function foo() { ->foo : Symbol(foo, Decl(1.ts, 4, 3)) +>foo : Symbol(foo, Decl(1.ts, 6, 30)) const p2 = import("./0"); ->p2 : Symbol(p2, Decl(1.ts, 7, 9)) +>p2 : Symbol(p2, Decl(1.ts, 9, 9)) >"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) } + +class C { +>C : Symbol(C, Decl(1.ts, 10, 1)) + + method() { +>method : Symbol(C.method, Decl(1.ts, 12, 9)) + + const loadAsync = import ("./0"); +>loadAsync : Symbol(loadAsync, Decl(1.ts, 14, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + } +} + +export class D { +>D : Symbol(D, Decl(1.ts, 16, 1)) + + method() { +>method : Symbol(D.method, Decl(1.ts, 18, 16)) + + const loadAsync = import ("./0"); +>loadAsync : Symbol(loadAsync, Decl(1.ts, 20, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + } +} diff --git a/tests/baselines/reference/importCallExpressionES5System.types b/tests/baselines/reference/importCallExpressionES5System.types index 59da055ee01..e97f722b14f 100644 --- a/tests/baselines/reference/importCallExpressionES5System.types +++ b/tests/baselines/reference/importCallExpressionES5System.types @@ -29,6 +29,11 @@ p1.then(zero => { }); +export var p2 = import("./0"); +>p2 : Promise +>import("./0") : Promise +>"./0" : "./0" + function foo() { >foo : () => void @@ -37,3 +42,29 @@ function foo() { >import("./0") : Promise >"./0" : "./0" } + +class C { +>C : C + + method() { +>method : () => void + + const loadAsync = import ("./0"); +>loadAsync : Promise +>import ("./0") : Promise +>"./0" : "./0" + } +} + +export class D { +>D : D + + method() { +>method : () => void + + const loadAsync = import ("./0"); +>loadAsync : Promise +>import ("./0") : Promise +>"./0" : "./0" + } +} diff --git a/tests/baselines/reference/importCallExpressionES5UMD.js b/tests/baselines/reference/importCallExpressionES5UMD.js index dfe6813839c..5727744aa71 100644 --- a/tests/baselines/reference/importCallExpressionES5UMD.js +++ b/tests/baselines/reference/importCallExpressionES5UMD.js @@ -10,8 +10,22 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); +} + +class C { + method() { + const loadAsync = import ("./0"); + } +} + +export class D { + method() { + const loadAsync = import ("./0"); + } } //// [0.js] @@ -41,12 +55,31 @@ function foo() { })(function (require, exports) { "use strict"; var __syncRequire = typeof module === "object" && typeof module.exports === "object"; + Object.defineProperty(exports, "__esModule", { value: true }); __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); }); var p1 = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); }); p1.then(function (zero) { return zero.foo(); }); + exports.p2 = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }); function foo() { - var p2 = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }); + var p2 = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_4, reject_4) { require(["./0"], resolve_4, reject_4); }); } + var C = (function () { + function C() { + } + C.prototype.method = function () { + var loadAsync = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_5, reject_5) { require(["./0"], resolve_5, reject_5); }); + }; + return C; + }()); + var D = (function () { + function D() { + } + D.prototype.method = function () { + var loadAsync = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_6, reject_6) { require(["./0"], resolve_6, reject_6); }); + }; + return D; + }()); + exports.D = D; }); diff --git a/tests/baselines/reference/importCallExpressionES5UMD.symbols b/tests/baselines/reference/importCallExpressionES5UMD.symbols index a1a506e7005..2f8bd23758d 100644 --- a/tests/baselines/reference/importCallExpressionES5UMD.symbols +++ b/tests/baselines/reference/importCallExpressionES5UMD.symbols @@ -23,10 +23,38 @@ p1.then(zero => { }); +export var p2 = import("./0"); +>p2 : Symbol(p2, Decl(1.ts, 6, 10)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + function foo() { ->foo : Symbol(foo, Decl(1.ts, 4, 3)) +>foo : Symbol(foo, Decl(1.ts, 6, 30)) const p2 = import("./0"); ->p2 : Symbol(p2, Decl(1.ts, 7, 9)) +>p2 : Symbol(p2, Decl(1.ts, 9, 9)) >"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) } + +class C { +>C : Symbol(C, Decl(1.ts, 10, 1)) + + method() { +>method : Symbol(C.method, Decl(1.ts, 12, 9)) + + const loadAsync = import ("./0"); +>loadAsync : Symbol(loadAsync, Decl(1.ts, 14, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + } +} + +export class D { +>D : Symbol(D, Decl(1.ts, 16, 1)) + + method() { +>method : Symbol(D.method, Decl(1.ts, 18, 16)) + + const loadAsync = import ("./0"); +>loadAsync : Symbol(loadAsync, Decl(1.ts, 20, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + } +} diff --git a/tests/baselines/reference/importCallExpressionES5UMD.types b/tests/baselines/reference/importCallExpressionES5UMD.types index 59da055ee01..e97f722b14f 100644 --- a/tests/baselines/reference/importCallExpressionES5UMD.types +++ b/tests/baselines/reference/importCallExpressionES5UMD.types @@ -29,6 +29,11 @@ p1.then(zero => { }); +export var p2 = import("./0"); +>p2 : Promise +>import("./0") : Promise +>"./0" : "./0" + function foo() { >foo : () => void @@ -37,3 +42,29 @@ function foo() { >import("./0") : Promise >"./0" : "./0" } + +class C { +>C : C + + method() { +>method : () => void + + const loadAsync = import ("./0"); +>loadAsync : Promise +>import ("./0") : Promise +>"./0" : "./0" + } +} + +export class D { +>D : D + + method() { +>method : () => void + + const loadAsync = import ("./0"); +>loadAsync : Promise +>import ("./0") : Promise +>"./0" : "./0" + } +} diff --git a/tests/baselines/reference/importCallExpressionES6AMD.js b/tests/baselines/reference/importCallExpressionES6AMD.js new file mode 100644 index 00000000000..08fec3b27fd --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES6AMD.js @@ -0,0 +1,62 @@ +//// [tests/cases/conformance/dynamicImport/importCallExpressionES6AMD.ts] //// + +//// [0.ts] +export function foo() { return "foo"; } + +//// [1.ts] +import("./0"); +var p1 = import("./0"); +p1.then(zero => { + return zero.foo(); +}); + +export var p2 = import("./0"); + +function foo() { + const p2 = import("./0"); +} + +class C { + method() { + const loadAsync = import ("./0"); + } +} + +export class D { + method() { + const loadAsync = import ("./0"); + } +} + +//// [0.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + function foo() { return "foo"; } + exports.foo = foo; +}); +//// [1.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); }); + var p1 = new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); }); + p1.then(zero => { + return zero.foo(); + }); + exports.p2 = new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }); + function foo() { + const p2 = new Promise(function (resolve_4, reject_4) { require(["./0"], resolve_4, reject_4); }); + } + class C { + method() { + const loadAsync = new Promise(function (resolve_5, reject_5) { require(["./0"], resolve_5, reject_5); }); + } + } + class D { + method() { + const loadAsync = new Promise(function (resolve_6, reject_6) { require(["./0"], resolve_6, reject_6); }); + } + } + exports.D = D; +}); diff --git a/tests/baselines/reference/importCallExpressionES6AMD.symbols b/tests/baselines/reference/importCallExpressionES6AMD.symbols new file mode 100644 index 00000000000..2f8bd23758d --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES6AMD.symbols @@ -0,0 +1,60 @@ +=== tests/cases/conformance/dynamicImport/0.ts === +export function foo() { return "foo"; } +>foo : Symbol(foo, Decl(0.ts, 0, 0)) + +=== tests/cases/conformance/dynamicImport/1.ts === +import("./0"); +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + +var p1 = import("./0"); +>p1 : Symbol(p1, Decl(1.ts, 1, 3)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + +p1.then(zero => { +>p1.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p1 : Symbol(p1, Decl(1.ts, 1, 3)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>zero : Symbol(zero, Decl(1.ts, 2, 8)) + + return zero.foo(); +>zero.foo : Symbol(foo, Decl(0.ts, 0, 0)) +>zero : Symbol(zero, Decl(1.ts, 2, 8)) +>foo : Symbol(foo, Decl(0.ts, 0, 0)) + +}); + +export var p2 = import("./0"); +>p2 : Symbol(p2, Decl(1.ts, 6, 10)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + +function foo() { +>foo : Symbol(foo, Decl(1.ts, 6, 30)) + + const p2 = import("./0"); +>p2 : Symbol(p2, Decl(1.ts, 9, 9)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) +} + +class C { +>C : Symbol(C, Decl(1.ts, 10, 1)) + + method() { +>method : Symbol(C.method, Decl(1.ts, 12, 9)) + + const loadAsync = import ("./0"); +>loadAsync : Symbol(loadAsync, Decl(1.ts, 14, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + } +} + +export class D { +>D : Symbol(D, Decl(1.ts, 16, 1)) + + method() { +>method : Symbol(D.method, Decl(1.ts, 18, 16)) + + const loadAsync = import ("./0"); +>loadAsync : Symbol(loadAsync, Decl(1.ts, 20, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + } +} diff --git a/tests/baselines/reference/importCallExpressionES6AMD.types b/tests/baselines/reference/importCallExpressionES6AMD.types new file mode 100644 index 00000000000..e97f722b14f --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES6AMD.types @@ -0,0 +1,70 @@ +=== tests/cases/conformance/dynamicImport/0.ts === +export function foo() { return "foo"; } +>foo : () => string +>"foo" : "foo" + +=== tests/cases/conformance/dynamicImport/1.ts === +import("./0"); +>import("./0") : Promise +>"./0" : "./0" + +var p1 = import("./0"); +>p1 : Promise +>import("./0") : Promise +>"./0" : "./0" + +p1.then(zero => { +>p1.then(zero => { return zero.foo();}) : Promise +>p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string +>zero : typeof "tests/cases/conformance/dynamicImport/0" + + return zero.foo(); +>zero.foo() : string +>zero.foo : () => string +>zero : typeof "tests/cases/conformance/dynamicImport/0" +>foo : () => string + +}); + +export var p2 = import("./0"); +>p2 : Promise +>import("./0") : Promise +>"./0" : "./0" + +function foo() { +>foo : () => void + + const p2 = import("./0"); +>p2 : Promise +>import("./0") : Promise +>"./0" : "./0" +} + +class C { +>C : C + + method() { +>method : () => void + + const loadAsync = import ("./0"); +>loadAsync : Promise +>import ("./0") : Promise +>"./0" : "./0" + } +} + +export class D { +>D : D + + method() { +>method : () => void + + const loadAsync = import ("./0"); +>loadAsync : Promise +>import ("./0") : Promise +>"./0" : "./0" + } +} diff --git a/tests/baselines/reference/importCallExpressionES6CJS.js b/tests/baselines/reference/importCallExpressionES6CJS.js new file mode 100644 index 00000000000..28833e17479 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES6CJS.js @@ -0,0 +1,58 @@ +//// [tests/cases/conformance/dynamicImport/importCallExpressionES6CJS.ts] //// + +//// [0.ts] +export function foo() { return "foo"; } + +//// [1.ts] +import("./0"); +var p1 = import("./0"); +p1.then(zero => { + return zero.foo(); +}); + +export var p2 = import("./0"); + +function foo() { + const p2 = import("./0"); +} + +class C { + method() { + const loadAsync = import ("./0"); + } +} + +export class D { + method() { + const loadAsync = import ("./0"); + } +} + +//// [0.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function foo() { return "foo"; } +exports.foo = foo; +//// [1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +Promise.resolve().then(function () { return require("./0"); }); +var p1 = Promise.resolve().then(function () { return require("./0"); }); +p1.then(zero => { + return zero.foo(); +}); +exports.p2 = Promise.resolve().then(function () { return require("./0"); }); +function foo() { + const p2 = Promise.resolve().then(function () { return require("./0"); }); +} +class C { + method() { + const loadAsync = Promise.resolve().then(function () { return require("./0"); }); + } +} +class D { + method() { + const loadAsync = Promise.resolve().then(function () { return require("./0"); }); + } +} +exports.D = D; diff --git a/tests/baselines/reference/importCallExpressionES6CJS.symbols b/tests/baselines/reference/importCallExpressionES6CJS.symbols new file mode 100644 index 00000000000..2f8bd23758d --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES6CJS.symbols @@ -0,0 +1,60 @@ +=== tests/cases/conformance/dynamicImport/0.ts === +export function foo() { return "foo"; } +>foo : Symbol(foo, Decl(0.ts, 0, 0)) + +=== tests/cases/conformance/dynamicImport/1.ts === +import("./0"); +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + +var p1 = import("./0"); +>p1 : Symbol(p1, Decl(1.ts, 1, 3)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + +p1.then(zero => { +>p1.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p1 : Symbol(p1, Decl(1.ts, 1, 3)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>zero : Symbol(zero, Decl(1.ts, 2, 8)) + + return zero.foo(); +>zero.foo : Symbol(foo, Decl(0.ts, 0, 0)) +>zero : Symbol(zero, Decl(1.ts, 2, 8)) +>foo : Symbol(foo, Decl(0.ts, 0, 0)) + +}); + +export var p2 = import("./0"); +>p2 : Symbol(p2, Decl(1.ts, 6, 10)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + +function foo() { +>foo : Symbol(foo, Decl(1.ts, 6, 30)) + + const p2 = import("./0"); +>p2 : Symbol(p2, Decl(1.ts, 9, 9)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) +} + +class C { +>C : Symbol(C, Decl(1.ts, 10, 1)) + + method() { +>method : Symbol(C.method, Decl(1.ts, 12, 9)) + + const loadAsync = import ("./0"); +>loadAsync : Symbol(loadAsync, Decl(1.ts, 14, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + } +} + +export class D { +>D : Symbol(D, Decl(1.ts, 16, 1)) + + method() { +>method : Symbol(D.method, Decl(1.ts, 18, 16)) + + const loadAsync = import ("./0"); +>loadAsync : Symbol(loadAsync, Decl(1.ts, 20, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + } +} diff --git a/tests/baselines/reference/importCallExpressionES6CJS.types b/tests/baselines/reference/importCallExpressionES6CJS.types new file mode 100644 index 00000000000..e97f722b14f --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES6CJS.types @@ -0,0 +1,70 @@ +=== tests/cases/conformance/dynamicImport/0.ts === +export function foo() { return "foo"; } +>foo : () => string +>"foo" : "foo" + +=== tests/cases/conformance/dynamicImport/1.ts === +import("./0"); +>import("./0") : Promise +>"./0" : "./0" + +var p1 = import("./0"); +>p1 : Promise +>import("./0") : Promise +>"./0" : "./0" + +p1.then(zero => { +>p1.then(zero => { return zero.foo();}) : Promise +>p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string +>zero : typeof "tests/cases/conformance/dynamicImport/0" + + return zero.foo(); +>zero.foo() : string +>zero.foo : () => string +>zero : typeof "tests/cases/conformance/dynamicImport/0" +>foo : () => string + +}); + +export var p2 = import("./0"); +>p2 : Promise +>import("./0") : Promise +>"./0" : "./0" + +function foo() { +>foo : () => void + + const p2 = import("./0"); +>p2 : Promise +>import("./0") : Promise +>"./0" : "./0" +} + +class C { +>C : C + + method() { +>method : () => void + + const loadAsync = import ("./0"); +>loadAsync : Promise +>import ("./0") : Promise +>"./0" : "./0" + } +} + +export class D { +>D : D + + method() { +>method : () => void + + const loadAsync = import ("./0"); +>loadAsync : Promise +>import ("./0") : Promise +>"./0" : "./0" + } +} diff --git a/tests/baselines/reference/importCallExpressionES6System.js b/tests/baselines/reference/importCallExpressionES6System.js new file mode 100644 index 00000000000..0676e4cd559 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES6System.js @@ -0,0 +1,73 @@ +//// [tests/cases/conformance/dynamicImport/importCallExpressionES6System.ts] //// + +//// [0.ts] +export function foo() { return "foo"; } + +//// [1.ts] +import("./0"); +var p1 = import("./0"); +p1.then(zero => { + return zero.foo(); +}); + +export var p2 = import("./0"); + +function foo() { + const p2 = import("./0"); +} + +class C { + method() { + const loadAsync = import ("./0"); + } +} + +export class D { + method() { + const loadAsync = import ("./0"); + } +} + +//// [0.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + function foo() { return "foo"; } + exports_1("foo", foo); + return { + setters: [], + execute: function () { + } + }; +}); +//// [1.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + function foo() { + const p2 = context_1.import("./0"); + } + var p1, p2, C, D; + return { + setters: [], + execute: function () { + context_1.import("./0"); + p1 = context_1.import("./0"); + p1.then(zero => { + return zero.foo(); + }); + exports_1("p2", p2 = context_1.import("./0")); + C = class C { + method() { + const loadAsync = context_1.import("./0"); + } + }; + D = class D { + method() { + const loadAsync = context_1.import("./0"); + } + }; + exports_1("D", D); + } + }; +}); diff --git a/tests/baselines/reference/importCallExpressionES6System.symbols b/tests/baselines/reference/importCallExpressionES6System.symbols new file mode 100644 index 00000000000..2f8bd23758d --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES6System.symbols @@ -0,0 +1,60 @@ +=== tests/cases/conformance/dynamicImport/0.ts === +export function foo() { return "foo"; } +>foo : Symbol(foo, Decl(0.ts, 0, 0)) + +=== tests/cases/conformance/dynamicImport/1.ts === +import("./0"); +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + +var p1 = import("./0"); +>p1 : Symbol(p1, Decl(1.ts, 1, 3)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + +p1.then(zero => { +>p1.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p1 : Symbol(p1, Decl(1.ts, 1, 3)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>zero : Symbol(zero, Decl(1.ts, 2, 8)) + + return zero.foo(); +>zero.foo : Symbol(foo, Decl(0.ts, 0, 0)) +>zero : Symbol(zero, Decl(1.ts, 2, 8)) +>foo : Symbol(foo, Decl(0.ts, 0, 0)) + +}); + +export var p2 = import("./0"); +>p2 : Symbol(p2, Decl(1.ts, 6, 10)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + +function foo() { +>foo : Symbol(foo, Decl(1.ts, 6, 30)) + + const p2 = import("./0"); +>p2 : Symbol(p2, Decl(1.ts, 9, 9)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) +} + +class C { +>C : Symbol(C, Decl(1.ts, 10, 1)) + + method() { +>method : Symbol(C.method, Decl(1.ts, 12, 9)) + + const loadAsync = import ("./0"); +>loadAsync : Symbol(loadAsync, Decl(1.ts, 14, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + } +} + +export class D { +>D : Symbol(D, Decl(1.ts, 16, 1)) + + method() { +>method : Symbol(D.method, Decl(1.ts, 18, 16)) + + const loadAsync = import ("./0"); +>loadAsync : Symbol(loadAsync, Decl(1.ts, 20, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + } +} diff --git a/tests/baselines/reference/importCallExpressionES6System.types b/tests/baselines/reference/importCallExpressionES6System.types new file mode 100644 index 00000000000..e97f722b14f --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES6System.types @@ -0,0 +1,70 @@ +=== tests/cases/conformance/dynamicImport/0.ts === +export function foo() { return "foo"; } +>foo : () => string +>"foo" : "foo" + +=== tests/cases/conformance/dynamicImport/1.ts === +import("./0"); +>import("./0") : Promise +>"./0" : "./0" + +var p1 = import("./0"); +>p1 : Promise +>import("./0") : Promise +>"./0" : "./0" + +p1.then(zero => { +>p1.then(zero => { return zero.foo();}) : Promise +>p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string +>zero : typeof "tests/cases/conformance/dynamicImport/0" + + return zero.foo(); +>zero.foo() : string +>zero.foo : () => string +>zero : typeof "tests/cases/conformance/dynamicImport/0" +>foo : () => string + +}); + +export var p2 = import("./0"); +>p2 : Promise +>import("./0") : Promise +>"./0" : "./0" + +function foo() { +>foo : () => void + + const p2 = import("./0"); +>p2 : Promise +>import("./0") : Promise +>"./0" : "./0" +} + +class C { +>C : C + + method() { +>method : () => void + + const loadAsync = import ("./0"); +>loadAsync : Promise +>import ("./0") : Promise +>"./0" : "./0" + } +} + +export class D { +>D : D + + method() { +>method : () => void + + const loadAsync = import ("./0"); +>loadAsync : Promise +>import ("./0") : Promise +>"./0" : "./0" + } +} diff --git a/tests/baselines/reference/importCallExpressionES6UMD.js b/tests/baselines/reference/importCallExpressionES6UMD.js new file mode 100644 index 00000000000..cc7dfef0074 --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES6UMD.js @@ -0,0 +1,79 @@ +//// [tests/cases/conformance/dynamicImport/importCallExpressionES6UMD.ts] //// + +//// [0.ts] +export function foo() { return "foo"; } + +//// [1.ts] +import("./0"); +var p1 = import("./0"); +p1.then(zero => { + return zero.foo(); +}); + +export var p2 = import("./0"); + +function foo() { + const p2 = import("./0"); +} + +class C { + method() { + const loadAsync = import ("./0"); + } +} + +export class D { + method() { + const loadAsync = import ("./0"); + } +} + +//// [0.js] +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; + } + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); + } +})(function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + function foo() { return "foo"; } + exports.foo = foo; +}); +//// [1.js] +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; + } + else if (typeof define === "function" && define.amd) { + define(["require", "exports"], factory); + } +})(function (require, exports) { + "use strict"; + var __syncRequire = typeof module === "object" && typeof module.exports === "object"; + Object.defineProperty(exports, "__esModule", { value: true }); + __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); }); + var p1 = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); }); + p1.then(zero => { + return zero.foo(); + }); + exports.p2 = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }); + function foo() { + const p2 = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_4, reject_4) { require(["./0"], resolve_4, reject_4); }); + } + class C { + method() { + const loadAsync = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_5, reject_5) { require(["./0"], resolve_5, reject_5); }); + } + } + class D { + method() { + const loadAsync = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_6, reject_6) { require(["./0"], resolve_6, reject_6); }); + } + } + exports.D = D; +}); diff --git a/tests/baselines/reference/importCallExpressionES6UMD.symbols b/tests/baselines/reference/importCallExpressionES6UMD.symbols new file mode 100644 index 00000000000..2f8bd23758d --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES6UMD.symbols @@ -0,0 +1,60 @@ +=== tests/cases/conformance/dynamicImport/0.ts === +export function foo() { return "foo"; } +>foo : Symbol(foo, Decl(0.ts, 0, 0)) + +=== tests/cases/conformance/dynamicImport/1.ts === +import("./0"); +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + +var p1 = import("./0"); +>p1 : Symbol(p1, Decl(1.ts, 1, 3)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + +p1.then(zero => { +>p1.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>p1 : Symbol(p1, Decl(1.ts, 1, 3)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>zero : Symbol(zero, Decl(1.ts, 2, 8)) + + return zero.foo(); +>zero.foo : Symbol(foo, Decl(0.ts, 0, 0)) +>zero : Symbol(zero, Decl(1.ts, 2, 8)) +>foo : Symbol(foo, Decl(0.ts, 0, 0)) + +}); + +export var p2 = import("./0"); +>p2 : Symbol(p2, Decl(1.ts, 6, 10)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + +function foo() { +>foo : Symbol(foo, Decl(1.ts, 6, 30)) + + const p2 = import("./0"); +>p2 : Symbol(p2, Decl(1.ts, 9, 9)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) +} + +class C { +>C : Symbol(C, Decl(1.ts, 10, 1)) + + method() { +>method : Symbol(C.method, Decl(1.ts, 12, 9)) + + const loadAsync = import ("./0"); +>loadAsync : Symbol(loadAsync, Decl(1.ts, 14, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + } +} + +export class D { +>D : Symbol(D, Decl(1.ts, 16, 1)) + + method() { +>method : Symbol(D.method, Decl(1.ts, 18, 16)) + + const loadAsync = import ("./0"); +>loadAsync : Symbol(loadAsync, Decl(1.ts, 20, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + } +} diff --git a/tests/baselines/reference/importCallExpressionES6UMD.types b/tests/baselines/reference/importCallExpressionES6UMD.types new file mode 100644 index 00000000000..e97f722b14f --- /dev/null +++ b/tests/baselines/reference/importCallExpressionES6UMD.types @@ -0,0 +1,70 @@ +=== tests/cases/conformance/dynamicImport/0.ts === +export function foo() { return "foo"; } +>foo : () => string +>"foo" : "foo" + +=== tests/cases/conformance/dynamicImport/1.ts === +import("./0"); +>import("./0") : Promise +>"./0" : "./0" + +var p1 = import("./0"); +>p1 : Promise +>import("./0") : Promise +>"./0" : "./0" + +p1.then(zero => { +>p1.then(zero => { return zero.foo();}) : Promise +>p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string +>zero : typeof "tests/cases/conformance/dynamicImport/0" + + return zero.foo(); +>zero.foo() : string +>zero.foo : () => string +>zero : typeof "tests/cases/conformance/dynamicImport/0" +>foo : () => string + +}); + +export var p2 = import("./0"); +>p2 : Promise +>import("./0") : Promise +>"./0" : "./0" + +function foo() { +>foo : () => void + + const p2 = import("./0"); +>p2 : Promise +>import("./0") : Promise +>"./0" : "./0" +} + +class C { +>C : C + + method() { +>method : () => void + + const loadAsync = import ("./0"); +>loadAsync : Promise +>import ("./0") : Promise +>"./0" : "./0" + } +} + +export class D { +>D : D + + method() { +>method : () => void + + const loadAsync = import ("./0"); +>loadAsync : Promise +>import ("./0") : Promise +>"./0" : "./0" + } +} diff --git a/tests/baselines/reference/importCallExpressionInAMD1.js b/tests/baselines/reference/importCallExpressionInAMD1.js index e1758173646..5c858160353 100644 --- a/tests/baselines/reference/importCallExpressionInAMD1.js +++ b/tests/baselines/reference/importCallExpressionInAMD1.js @@ -10,6 +10,8 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); } @@ -24,12 +26,14 @@ define(["require", "exports"], function (require, exports) { //// [1.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); }); var p1 = new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); }); p1.then(zero => { return zero.foo(); }); + exports.p2 = new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }); function foo() { - const p2 = new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }); + const p2 = new Promise(function (resolve_4, reject_4) { require(["./0"], resolve_4, reject_4); }); } }); diff --git a/tests/baselines/reference/importCallExpressionInAMD1.symbols b/tests/baselines/reference/importCallExpressionInAMD1.symbols index a1a506e7005..839f7d0d6da 100644 --- a/tests/baselines/reference/importCallExpressionInAMD1.symbols +++ b/tests/baselines/reference/importCallExpressionInAMD1.symbols @@ -23,10 +23,14 @@ p1.then(zero => { }); +export var p2 = import("./0"); +>p2 : Symbol(p2, Decl(1.ts, 6, 10)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + function foo() { ->foo : Symbol(foo, Decl(1.ts, 4, 3)) +>foo : Symbol(foo, Decl(1.ts, 6, 30)) const p2 = import("./0"); ->p2 : Symbol(p2, Decl(1.ts, 7, 9)) +>p2 : Symbol(p2, Decl(1.ts, 9, 9)) >"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) } diff --git a/tests/baselines/reference/importCallExpressionInAMD1.types b/tests/baselines/reference/importCallExpressionInAMD1.types index 59da055ee01..661d27d1469 100644 --- a/tests/baselines/reference/importCallExpressionInAMD1.types +++ b/tests/baselines/reference/importCallExpressionInAMD1.types @@ -29,6 +29,11 @@ p1.then(zero => { }); +export var p2 = import("./0"); +>p2 : Promise +>import("./0") : Promise +>"./0" : "./0" + function foo() { >foo : () => void diff --git a/tests/baselines/reference/importCallExpressionInAMD4.js b/tests/baselines/reference/importCallExpressionInAMD4.js index 6e50e139116..43ba5afcd30 100644 --- a/tests/baselines/reference/importCallExpressionInAMD4.js +++ b/tests/baselines/reference/importCallExpressionInAMD4.js @@ -15,6 +15,21 @@ declare var console: any; class C { private myModule = import("./0"); method() { + const loadAsync = import("./0"); + this.myModule.then(Zero => { + console.log(Zero.foo()); + }, async err => { + console.log(err); + let one = await import("./1"); + console.log(one.backup()); + }); + } +} + +export class D { + private myModule = import("./0"); + method() { + const loadAsync = import("./0"); this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { @@ -46,18 +61,36 @@ define(["require", "exports"], function (require, exports) { //// [2.js] define(["require", "exports"], function (require, exports) { "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); class C { constructor() { this.myModule = new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); }); } method() { + const loadAsync = new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); }); this.myModule.then(Zero => { console.log(Zero.foo()); }, async (err) => { console.log(err); - let one = await new Promise(function (resolve_2, reject_2) { require(["./1"], resolve_2, reject_2); }); + let one = await new Promise(function (resolve_3, reject_3) { require(["./1"], resolve_3, reject_3); }); console.log(one.backup()); }); } } + class D { + constructor() { + this.myModule = new Promise(function (resolve_4, reject_4) { require(["./0"], resolve_4, reject_4); }); + } + method() { + const loadAsync = new Promise(function (resolve_5, reject_5) { require(["./0"], resolve_5, reject_5); }); + this.myModule.then(Zero => { + console.log(Zero.foo()); + }, async (err) => { + console.log(err); + let one = await new Promise(function (resolve_6, reject_6) { require(["./1"], resolve_6, reject_6); }); + console.log(one.backup()); + }); + } + } + exports.D = D; }); diff --git a/tests/baselines/reference/importCallExpressionInAMD4.symbols b/tests/baselines/reference/importCallExpressionInAMD4.symbols index b02646d5e3d..c4de50e5bc4 100644 --- a/tests/baselines/reference/importCallExpressionInAMD4.symbols +++ b/tests/baselines/reference/importCallExpressionInAMD4.symbols @@ -27,35 +27,88 @@ class C { method() { >method : Symbol(C.method, Decl(2.ts, 2, 37)) + const loadAsync = import("./0"); +>loadAsync : Symbol(loadAsync, Decl(2.ts, 4, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + this.myModule.then(Zero => { >this.myModule.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >this.myModule : Symbol(C.myModule, Decl(2.ts, 1, 9)) >this : Symbol(C, Decl(2.ts, 0, 25)) >myModule : Symbol(C.myModule, Decl(2.ts, 1, 9)) >then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) ->Zero : Symbol(Zero, Decl(2.ts, 4, 27)) +>Zero : Symbol(Zero, Decl(2.ts, 5, 27)) console.log(Zero.foo()); >console : Symbol(console, Decl(2.ts, 0, 11)) >Zero.foo : Symbol(foo, Decl(0.ts, 2, 1)) ->Zero : Symbol(Zero, Decl(2.ts, 4, 27)) +>Zero : Symbol(Zero, Decl(2.ts, 5, 27)) >foo : Symbol(foo, Decl(0.ts, 2, 1)) }, async err => { ->err : Symbol(err, Decl(2.ts, 6, 16)) +>err : Symbol(err, Decl(2.ts, 7, 16)) console.log(err); >console : Symbol(console, Decl(2.ts, 0, 11)) ->err : Symbol(err, Decl(2.ts, 6, 16)) +>err : Symbol(err, Decl(2.ts, 7, 16)) let one = await import("./1"); ->one : Symbol(one, Decl(2.ts, 8, 15)) +>one : Symbol(one, Decl(2.ts, 9, 15)) >"./1" : Symbol("tests/cases/conformance/dynamicImport/1", Decl(1.ts, 0, 0)) console.log(one.backup()); >console : Symbol(console, Decl(2.ts, 0, 11)) >one.backup : Symbol(backup, Decl(1.ts, 0, 0)) ->one : Symbol(one, Decl(2.ts, 8, 15)) +>one : Symbol(one, Decl(2.ts, 9, 15)) +>backup : Symbol(backup, Decl(1.ts, 0, 0)) + + }); + } +} + +export class D { +>D : Symbol(D, Decl(2.ts, 13, 1)) + + private myModule = import("./0"); +>myModule : Symbol(D.myModule, Decl(2.ts, 15, 16)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + + method() { +>method : Symbol(D.method, Decl(2.ts, 16, 37)) + + const loadAsync = import("./0"); +>loadAsync : Symbol(loadAsync, Decl(2.ts, 18, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + + this.myModule.then(Zero => { +>this.myModule.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>this.myModule : Symbol(D.myModule, Decl(2.ts, 15, 16)) +>this : Symbol(D, Decl(2.ts, 13, 1)) +>myModule : Symbol(D.myModule, Decl(2.ts, 15, 16)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Zero : Symbol(Zero, Decl(2.ts, 19, 27)) + + console.log(Zero.foo()); +>console : Symbol(console, Decl(2.ts, 0, 11)) +>Zero.foo : Symbol(foo, Decl(0.ts, 2, 1)) +>Zero : Symbol(Zero, Decl(2.ts, 19, 27)) +>foo : Symbol(foo, Decl(0.ts, 2, 1)) + + }, async err => { +>err : Symbol(err, Decl(2.ts, 21, 16)) + + console.log(err); +>console : Symbol(console, Decl(2.ts, 0, 11)) +>err : Symbol(err, Decl(2.ts, 21, 16)) + + let one = await import("./1"); +>one : Symbol(one, Decl(2.ts, 23, 15)) +>"./1" : Symbol("tests/cases/conformance/dynamicImport/1", Decl(1.ts, 0, 0)) + + console.log(one.backup()); +>console : Symbol(console, Decl(2.ts, 0, 11)) +>one.backup : Symbol(backup, Decl(1.ts, 0, 0)) +>one : Symbol(one, Decl(2.ts, 23, 15)) >backup : Symbol(backup, Decl(1.ts, 0, 0)) }); diff --git a/tests/baselines/reference/importCallExpressionInAMD4.types b/tests/baselines/reference/importCallExpressionInAMD4.types index 2ea666ba672..156247851c9 100644 --- a/tests/baselines/reference/importCallExpressionInAMD4.types +++ b/tests/baselines/reference/importCallExpressionInAMD4.types @@ -31,6 +31,78 @@ class C { method() { >method : () => void + const loadAsync = import("./0"); +>loadAsync : Promise +>import("./0") : Promise +>"./0" : "./0" + + this.myModule.then(Zero => { +>this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise +>this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>this.myModule : Promise +>this : this +>myModule : Promise +>then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void +>Zero : typeof "tests/cases/conformance/dynamicImport/0" + + console.log(Zero.foo()); +>console.log(Zero.foo()) : any +>console.log : any +>console : any +>log : any +>Zero.foo() : string +>Zero.foo : () => string +>Zero : typeof "tests/cases/conformance/dynamicImport/0" +>foo : () => string + + }, async err => { +>async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); } : (err: any) => Promise +>err : any + + console.log(err); +>console.log(err) : any +>console.log : any +>console : any +>log : any +>err : any + + let one = await import("./1"); +>one : typeof "tests/cases/conformance/dynamicImport/1" +>await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" +>import("./1") : Promise +>"./1" : "./1" + + console.log(one.backup()); +>console.log(one.backup()) : any +>console.log : any +>console : any +>log : any +>one.backup() : string +>one.backup : () => string +>one : typeof "tests/cases/conformance/dynamicImport/1" +>backup : () => string + + }); + } +} + +export class D { +>D : D + + private myModule = import("./0"); +>myModule : Promise +>import("./0") : Promise +>"./0" : "./0" + + method() { +>method : () => void + + const loadAsync = import("./0"); +>loadAsync : Promise +>import("./0") : Promise +>"./0" : "./0" + this.myModule.then(Zero => { >this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise >this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise diff --git a/tests/baselines/reference/importCallExpressionInCJS1.js b/tests/baselines/reference/importCallExpressionInCJS1.js index 3fb298b5bde..359e743144b 100644 --- a/tests/baselines/reference/importCallExpressionInCJS1.js +++ b/tests/baselines/reference/importCallExpressionInCJS1.js @@ -10,6 +10,8 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); } @@ -20,11 +22,14 @@ Object.defineProperty(exports, "__esModule", { value: true }); function foo() { return "foo"; } exports.foo = foo; //// [1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); Promise.resolve().then(function () { return require("./0"); }); var p1 = Promise.resolve().then(function () { return require("./0"); }); p1.then(zero => { return zero.foo(); }); +exports.p2 = Promise.resolve().then(function () { return require("./0"); }); function foo() { const p2 = Promise.resolve().then(function () { return require("./0"); }); } diff --git a/tests/baselines/reference/importCallExpressionInCJS1.symbols b/tests/baselines/reference/importCallExpressionInCJS1.symbols index a1a506e7005..839f7d0d6da 100644 --- a/tests/baselines/reference/importCallExpressionInCJS1.symbols +++ b/tests/baselines/reference/importCallExpressionInCJS1.symbols @@ -23,10 +23,14 @@ p1.then(zero => { }); +export var p2 = import("./0"); +>p2 : Symbol(p2, Decl(1.ts, 6, 10)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + function foo() { ->foo : Symbol(foo, Decl(1.ts, 4, 3)) +>foo : Symbol(foo, Decl(1.ts, 6, 30)) const p2 = import("./0"); ->p2 : Symbol(p2, Decl(1.ts, 7, 9)) +>p2 : Symbol(p2, Decl(1.ts, 9, 9)) >"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) } diff --git a/tests/baselines/reference/importCallExpressionInCJS1.types b/tests/baselines/reference/importCallExpressionInCJS1.types index 59da055ee01..661d27d1469 100644 --- a/tests/baselines/reference/importCallExpressionInCJS1.types +++ b/tests/baselines/reference/importCallExpressionInCJS1.types @@ -29,6 +29,11 @@ p1.then(zero => { }); +export var p2 = import("./0"); +>p2 : Promise +>import("./0") : Promise +>"./0" : "./0" + function foo() { >foo : () => void diff --git a/tests/baselines/reference/importCallExpressionInCJS5.js b/tests/baselines/reference/importCallExpressionInCJS5.js index 762da592827..eeb4db275fa 100644 --- a/tests/baselines/reference/importCallExpressionInCJS5.js +++ b/tests/baselines/reference/importCallExpressionInCJS5.js @@ -15,6 +15,21 @@ declare var console: any; class C { private myModule = import("./0"); method() { + const loadAsync = import ("./0"); + this.myModule.then(Zero => { + console.log(Zero.foo()); + }, async err => { + console.log(err); + let one = await import("./1"); + console.log(one.backup()); + }); + } +} + +export class D { + private myModule = import("./0"); + method() { + const loadAsync = import("./0"); this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { @@ -40,11 +55,14 @@ Object.defineProperty(exports, "__esModule", { value: true }); function backup() { return "backup"; } exports.backup = backup; //// [2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); class C { constructor() { this.myModule = Promise.resolve().then(function () { return require("./0"); }); } method() { + const loadAsync = Promise.resolve().then(function () { return require("./0"); }); this.myModule.then(Zero => { console.log(Zero.foo()); }, async (err) => { @@ -54,3 +72,19 @@ class C { }); } } +class D { + constructor() { + this.myModule = Promise.resolve().then(function () { return require("./0"); }); + } + method() { + const loadAsync = Promise.resolve().then(function () { return require("./0"); }); + this.myModule.then(Zero => { + console.log(Zero.foo()); + }, async (err) => { + console.log(err); + let one = await Promise.resolve().then(function () { return require("./1"); }); + console.log(one.backup()); + }); + } +} +exports.D = D; diff --git a/tests/baselines/reference/importCallExpressionInCJS5.symbols b/tests/baselines/reference/importCallExpressionInCJS5.symbols index b02646d5e3d..ed4baf00fe8 100644 --- a/tests/baselines/reference/importCallExpressionInCJS5.symbols +++ b/tests/baselines/reference/importCallExpressionInCJS5.symbols @@ -27,35 +27,88 @@ class C { method() { >method : Symbol(C.method, Decl(2.ts, 2, 37)) + const loadAsync = import ("./0"); +>loadAsync : Symbol(loadAsync, Decl(2.ts, 4, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + this.myModule.then(Zero => { >this.myModule.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >this.myModule : Symbol(C.myModule, Decl(2.ts, 1, 9)) >this : Symbol(C, Decl(2.ts, 0, 25)) >myModule : Symbol(C.myModule, Decl(2.ts, 1, 9)) >then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) ->Zero : Symbol(Zero, Decl(2.ts, 4, 27)) +>Zero : Symbol(Zero, Decl(2.ts, 5, 27)) console.log(Zero.foo()); >console : Symbol(console, Decl(2.ts, 0, 11)) >Zero.foo : Symbol(foo, Decl(0.ts, 2, 1)) ->Zero : Symbol(Zero, Decl(2.ts, 4, 27)) +>Zero : Symbol(Zero, Decl(2.ts, 5, 27)) >foo : Symbol(foo, Decl(0.ts, 2, 1)) }, async err => { ->err : Symbol(err, Decl(2.ts, 6, 16)) +>err : Symbol(err, Decl(2.ts, 7, 16)) console.log(err); >console : Symbol(console, Decl(2.ts, 0, 11)) ->err : Symbol(err, Decl(2.ts, 6, 16)) +>err : Symbol(err, Decl(2.ts, 7, 16)) let one = await import("./1"); ->one : Symbol(one, Decl(2.ts, 8, 15)) +>one : Symbol(one, Decl(2.ts, 9, 15)) >"./1" : Symbol("tests/cases/conformance/dynamicImport/1", Decl(1.ts, 0, 0)) console.log(one.backup()); >console : Symbol(console, Decl(2.ts, 0, 11)) >one.backup : Symbol(backup, Decl(1.ts, 0, 0)) ->one : Symbol(one, Decl(2.ts, 8, 15)) +>one : Symbol(one, Decl(2.ts, 9, 15)) +>backup : Symbol(backup, Decl(1.ts, 0, 0)) + + }); + } +} + +export class D { +>D : Symbol(D, Decl(2.ts, 13, 1)) + + private myModule = import("./0"); +>myModule : Symbol(D.myModule, Decl(2.ts, 15, 16)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + + method() { +>method : Symbol(D.method, Decl(2.ts, 16, 37)) + + const loadAsync = import("./0"); +>loadAsync : Symbol(loadAsync, Decl(2.ts, 18, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + + this.myModule.then(Zero => { +>this.myModule.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>this.myModule : Symbol(D.myModule, Decl(2.ts, 15, 16)) +>this : Symbol(D, Decl(2.ts, 13, 1)) +>myModule : Symbol(D.myModule, Decl(2.ts, 15, 16)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Zero : Symbol(Zero, Decl(2.ts, 19, 27)) + + console.log(Zero.foo()); +>console : Symbol(console, Decl(2.ts, 0, 11)) +>Zero.foo : Symbol(foo, Decl(0.ts, 2, 1)) +>Zero : Symbol(Zero, Decl(2.ts, 19, 27)) +>foo : Symbol(foo, Decl(0.ts, 2, 1)) + + }, async err => { +>err : Symbol(err, Decl(2.ts, 21, 16)) + + console.log(err); +>console : Symbol(console, Decl(2.ts, 0, 11)) +>err : Symbol(err, Decl(2.ts, 21, 16)) + + let one = await import("./1"); +>one : Symbol(one, Decl(2.ts, 23, 15)) +>"./1" : Symbol("tests/cases/conformance/dynamicImport/1", Decl(1.ts, 0, 0)) + + console.log(one.backup()); +>console : Symbol(console, Decl(2.ts, 0, 11)) +>one.backup : Symbol(backup, Decl(1.ts, 0, 0)) +>one : Symbol(one, Decl(2.ts, 23, 15)) >backup : Symbol(backup, Decl(1.ts, 0, 0)) }); diff --git a/tests/baselines/reference/importCallExpressionInCJS5.types b/tests/baselines/reference/importCallExpressionInCJS5.types index 2ea666ba672..7d0c6f01cac 100644 --- a/tests/baselines/reference/importCallExpressionInCJS5.types +++ b/tests/baselines/reference/importCallExpressionInCJS5.types @@ -31,6 +31,78 @@ class C { method() { >method : () => void + const loadAsync = import ("./0"); +>loadAsync : Promise +>import ("./0") : Promise +>"./0" : "./0" + + this.myModule.then(Zero => { +>this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise +>this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>this.myModule : Promise +>this : this +>myModule : Promise +>then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void +>Zero : typeof "tests/cases/conformance/dynamicImport/0" + + console.log(Zero.foo()); +>console.log(Zero.foo()) : any +>console.log : any +>console : any +>log : any +>Zero.foo() : string +>Zero.foo : () => string +>Zero : typeof "tests/cases/conformance/dynamicImport/0" +>foo : () => string + + }, async err => { +>async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); } : (err: any) => Promise +>err : any + + console.log(err); +>console.log(err) : any +>console.log : any +>console : any +>log : any +>err : any + + let one = await import("./1"); +>one : typeof "tests/cases/conformance/dynamicImport/1" +>await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" +>import("./1") : Promise +>"./1" : "./1" + + console.log(one.backup()); +>console.log(one.backup()) : any +>console.log : any +>console : any +>log : any +>one.backup() : string +>one.backup : () => string +>one : typeof "tests/cases/conformance/dynamicImport/1" +>backup : () => string + + }); + } +} + +export class D { +>D : D + + private myModule = import("./0"); +>myModule : Promise +>import("./0") : Promise +>"./0" : "./0" + + method() { +>method : () => void + + const loadAsync = import("./0"); +>loadAsync : Promise +>import("./0") : Promise +>"./0" : "./0" + this.myModule.then(Zero => { >this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise >this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise diff --git a/tests/baselines/reference/importCallExpressionInSystem1.js b/tests/baselines/reference/importCallExpressionInSystem1.js index d74eb6ffc76..74df68fc9a1 100644 --- a/tests/baselines/reference/importCallExpressionInSystem1.js +++ b/tests/baselines/reference/importCallExpressionInSystem1.js @@ -10,6 +10,8 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); } @@ -28,11 +30,12 @@ System.register([], function (exports_1, context_1) { }); //// [1.js] System.register([], function (exports_1, context_1) { + "use strict"; var __moduleName = context_1 && context_1.id; function foo() { const p2 = context_1.import("./0"); } - var p1; + var p1, p2; return { setters: [], execute: function () { @@ -41,6 +44,7 @@ System.register([], function (exports_1, context_1) { p1.then(zero => { return zero.foo(); }); + exports_1("p2", p2 = context_1.import("./0")); } }; }); diff --git a/tests/baselines/reference/importCallExpressionInSystem1.symbols b/tests/baselines/reference/importCallExpressionInSystem1.symbols index a1a506e7005..839f7d0d6da 100644 --- a/tests/baselines/reference/importCallExpressionInSystem1.symbols +++ b/tests/baselines/reference/importCallExpressionInSystem1.symbols @@ -23,10 +23,14 @@ p1.then(zero => { }); +export var p2 = import("./0"); +>p2 : Symbol(p2, Decl(1.ts, 6, 10)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + function foo() { ->foo : Symbol(foo, Decl(1.ts, 4, 3)) +>foo : Symbol(foo, Decl(1.ts, 6, 30)) const p2 = import("./0"); ->p2 : Symbol(p2, Decl(1.ts, 7, 9)) +>p2 : Symbol(p2, Decl(1.ts, 9, 9)) >"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) } diff --git a/tests/baselines/reference/importCallExpressionInSystem1.types b/tests/baselines/reference/importCallExpressionInSystem1.types index 59da055ee01..661d27d1469 100644 --- a/tests/baselines/reference/importCallExpressionInSystem1.types +++ b/tests/baselines/reference/importCallExpressionInSystem1.types @@ -29,6 +29,11 @@ p1.then(zero => { }); +export var p2 = import("./0"); +>p2 : Promise +>import("./0") : Promise +>"./0" : "./0" + function foo() { >foo : () => void diff --git a/tests/baselines/reference/importCallExpressionInSystem4.js b/tests/baselines/reference/importCallExpressionInSystem4.js index ac01a0439e8..b7bc1f51fe5 100644 --- a/tests/baselines/reference/importCallExpressionInSystem4.js +++ b/tests/baselines/reference/importCallExpressionInSystem4.js @@ -15,6 +15,21 @@ declare var console: any; class C { private myModule = import("./0"); method() { + const loadAsync = import("./0"); + this.myModule.then(Zero => { + console.log(Zero.foo()); + }, async err => { + console.log(err); + let one = await import("./1"); + console.log(one.backup()); + }); + } +} + +export class D { + private myModule = import("./0"); + method() { + const loadAsync = import("./0"); this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { @@ -56,8 +71,9 @@ System.register([], function (exports_1, context_1) { }); //// [2.js] System.register([], function (exports_1, context_1) { + "use strict"; var __moduleName = context_1 && context_1.id; - var C; + var C, D; return { setters: [], execute: function () { @@ -66,6 +82,7 @@ System.register([], function (exports_1, context_1) { this.myModule = context_1.import("./0"); } method() { + const loadAsync = context_1.import("./0"); this.myModule.then(Zero => { console.log(Zero.foo()); }, async (err) => { @@ -75,6 +92,22 @@ System.register([], function (exports_1, context_1) { }); } }; + D = class D { + constructor() { + this.myModule = context_1.import("./0"); + } + method() { + const loadAsync = context_1.import("./0"); + this.myModule.then(Zero => { + console.log(Zero.foo()); + }, async (err) => { + console.log(err); + let one = await context_1.import("./1"); + console.log(one.backup()); + }); + } + }; + exports_1("D", D); } }; }); diff --git a/tests/baselines/reference/importCallExpressionInSystem4.symbols b/tests/baselines/reference/importCallExpressionInSystem4.symbols index b02646d5e3d..c4de50e5bc4 100644 --- a/tests/baselines/reference/importCallExpressionInSystem4.symbols +++ b/tests/baselines/reference/importCallExpressionInSystem4.symbols @@ -27,35 +27,88 @@ class C { method() { >method : Symbol(C.method, Decl(2.ts, 2, 37)) + const loadAsync = import("./0"); +>loadAsync : Symbol(loadAsync, Decl(2.ts, 4, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + this.myModule.then(Zero => { >this.myModule.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >this.myModule : Symbol(C.myModule, Decl(2.ts, 1, 9)) >this : Symbol(C, Decl(2.ts, 0, 25)) >myModule : Symbol(C.myModule, Decl(2.ts, 1, 9)) >then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) ->Zero : Symbol(Zero, Decl(2.ts, 4, 27)) +>Zero : Symbol(Zero, Decl(2.ts, 5, 27)) console.log(Zero.foo()); >console : Symbol(console, Decl(2.ts, 0, 11)) >Zero.foo : Symbol(foo, Decl(0.ts, 2, 1)) ->Zero : Symbol(Zero, Decl(2.ts, 4, 27)) +>Zero : Symbol(Zero, Decl(2.ts, 5, 27)) >foo : Symbol(foo, Decl(0.ts, 2, 1)) }, async err => { ->err : Symbol(err, Decl(2.ts, 6, 16)) +>err : Symbol(err, Decl(2.ts, 7, 16)) console.log(err); >console : Symbol(console, Decl(2.ts, 0, 11)) ->err : Symbol(err, Decl(2.ts, 6, 16)) +>err : Symbol(err, Decl(2.ts, 7, 16)) let one = await import("./1"); ->one : Symbol(one, Decl(2.ts, 8, 15)) +>one : Symbol(one, Decl(2.ts, 9, 15)) >"./1" : Symbol("tests/cases/conformance/dynamicImport/1", Decl(1.ts, 0, 0)) console.log(one.backup()); >console : Symbol(console, Decl(2.ts, 0, 11)) >one.backup : Symbol(backup, Decl(1.ts, 0, 0)) ->one : Symbol(one, Decl(2.ts, 8, 15)) +>one : Symbol(one, Decl(2.ts, 9, 15)) +>backup : Symbol(backup, Decl(1.ts, 0, 0)) + + }); + } +} + +export class D { +>D : Symbol(D, Decl(2.ts, 13, 1)) + + private myModule = import("./0"); +>myModule : Symbol(D.myModule, Decl(2.ts, 15, 16)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + + method() { +>method : Symbol(D.method, Decl(2.ts, 16, 37)) + + const loadAsync = import("./0"); +>loadAsync : Symbol(loadAsync, Decl(2.ts, 18, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + + this.myModule.then(Zero => { +>this.myModule.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>this.myModule : Symbol(D.myModule, Decl(2.ts, 15, 16)) +>this : Symbol(D, Decl(2.ts, 13, 1)) +>myModule : Symbol(D.myModule, Decl(2.ts, 15, 16)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Zero : Symbol(Zero, Decl(2.ts, 19, 27)) + + console.log(Zero.foo()); +>console : Symbol(console, Decl(2.ts, 0, 11)) +>Zero.foo : Symbol(foo, Decl(0.ts, 2, 1)) +>Zero : Symbol(Zero, Decl(2.ts, 19, 27)) +>foo : Symbol(foo, Decl(0.ts, 2, 1)) + + }, async err => { +>err : Symbol(err, Decl(2.ts, 21, 16)) + + console.log(err); +>console : Symbol(console, Decl(2.ts, 0, 11)) +>err : Symbol(err, Decl(2.ts, 21, 16)) + + let one = await import("./1"); +>one : Symbol(one, Decl(2.ts, 23, 15)) +>"./1" : Symbol("tests/cases/conformance/dynamicImport/1", Decl(1.ts, 0, 0)) + + console.log(one.backup()); +>console : Symbol(console, Decl(2.ts, 0, 11)) +>one.backup : Symbol(backup, Decl(1.ts, 0, 0)) +>one : Symbol(one, Decl(2.ts, 23, 15)) >backup : Symbol(backup, Decl(1.ts, 0, 0)) }); diff --git a/tests/baselines/reference/importCallExpressionInSystem4.types b/tests/baselines/reference/importCallExpressionInSystem4.types index 2ea666ba672..156247851c9 100644 --- a/tests/baselines/reference/importCallExpressionInSystem4.types +++ b/tests/baselines/reference/importCallExpressionInSystem4.types @@ -31,6 +31,78 @@ class C { method() { >method : () => void + const loadAsync = import("./0"); +>loadAsync : Promise +>import("./0") : Promise +>"./0" : "./0" + + this.myModule.then(Zero => { +>this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise +>this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>this.myModule : Promise +>this : this +>myModule : Promise +>then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void +>Zero : typeof "tests/cases/conformance/dynamicImport/0" + + console.log(Zero.foo()); +>console.log(Zero.foo()) : any +>console.log : any +>console : any +>log : any +>Zero.foo() : string +>Zero.foo : () => string +>Zero : typeof "tests/cases/conformance/dynamicImport/0" +>foo : () => string + + }, async err => { +>async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); } : (err: any) => Promise +>err : any + + console.log(err); +>console.log(err) : any +>console.log : any +>console : any +>log : any +>err : any + + let one = await import("./1"); +>one : typeof "tests/cases/conformance/dynamicImport/1" +>await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" +>import("./1") : Promise +>"./1" : "./1" + + console.log(one.backup()); +>console.log(one.backup()) : any +>console.log : any +>console : any +>log : any +>one.backup() : string +>one.backup : () => string +>one : typeof "tests/cases/conformance/dynamicImport/1" +>backup : () => string + + }); + } +} + +export class D { +>D : D + + private myModule = import("./0"); +>myModule : Promise +>import("./0") : Promise +>"./0" : "./0" + + method() { +>method : () => void + + const loadAsync = import("./0"); +>loadAsync : Promise +>import("./0") : Promise +>"./0" : "./0" + this.myModule.then(Zero => { >this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise >this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise diff --git a/tests/baselines/reference/importCallExpressionInUMD1.js b/tests/baselines/reference/importCallExpressionInUMD1.js index f1bfcd3cc71..ee99468f7f3 100644 --- a/tests/baselines/reference/importCallExpressionInUMD1.js +++ b/tests/baselines/reference/importCallExpressionInUMD1.js @@ -10,6 +10,8 @@ p1.then(zero => { return zero.foo(); }); +export var p2 = import("./0"); + function foo() { const p2 = import("./0"); } @@ -41,12 +43,14 @@ function foo() { })(function (require, exports) { "use strict"; var __syncRequire = typeof module === "object" && typeof module.exports === "object"; + Object.defineProperty(exports, "__esModule", { value: true }); __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); }); var p1 = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); }); p1.then(zero => { return zero.foo(); }); + exports.p2 = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }); function foo() { - const p2 = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }); + const p2 = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_4, reject_4) { require(["./0"], resolve_4, reject_4); }); } }); diff --git a/tests/baselines/reference/importCallExpressionInUMD1.symbols b/tests/baselines/reference/importCallExpressionInUMD1.symbols index a1a506e7005..839f7d0d6da 100644 --- a/tests/baselines/reference/importCallExpressionInUMD1.symbols +++ b/tests/baselines/reference/importCallExpressionInUMD1.symbols @@ -23,10 +23,14 @@ p1.then(zero => { }); +export var p2 = import("./0"); +>p2 : Symbol(p2, Decl(1.ts, 6, 10)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + function foo() { ->foo : Symbol(foo, Decl(1.ts, 4, 3)) +>foo : Symbol(foo, Decl(1.ts, 6, 30)) const p2 = import("./0"); ->p2 : Symbol(p2, Decl(1.ts, 7, 9)) +>p2 : Symbol(p2, Decl(1.ts, 9, 9)) >"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) } diff --git a/tests/baselines/reference/importCallExpressionInUMD1.types b/tests/baselines/reference/importCallExpressionInUMD1.types index 59da055ee01..661d27d1469 100644 --- a/tests/baselines/reference/importCallExpressionInUMD1.types +++ b/tests/baselines/reference/importCallExpressionInUMD1.types @@ -29,6 +29,11 @@ p1.then(zero => { }); +export var p2 = import("./0"); +>p2 : Promise +>import("./0") : Promise +>"./0" : "./0" + function foo() { >foo : () => void diff --git a/tests/baselines/reference/importCallExpressionInUMD4.js b/tests/baselines/reference/importCallExpressionInUMD4.js index 47ba83b1718..477a7826bc0 100644 --- a/tests/baselines/reference/importCallExpressionInUMD4.js +++ b/tests/baselines/reference/importCallExpressionInUMD4.js @@ -15,6 +15,21 @@ declare var console: any; class C { private myModule = import("./0"); method() { + const loadAsync = import("./0"); + this.myModule.then(Zero => { + console.log(Zero.foo()); + }, async err => { + console.log(err); + let one = await import("./1"); + console.log(one.backup()); + }); + } +} + +export class D { + private myModule = import("./0"); + method() { + const loadAsync = import("./0"); this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { @@ -71,18 +86,36 @@ class C { })(function (require, exports) { "use strict"; var __syncRequire = typeof module === "object" && typeof module.exports === "object"; + Object.defineProperty(exports, "__esModule", { value: true }); class C { constructor() { this.myModule = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); }); } method() { + const loadAsync = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); }); this.myModule.then(Zero => { console.log(Zero.foo()); }, async (err) => { console.log(err); - let one = await (__syncRequire ? Promise.resolve().then(function () { return require("./1"); }) : new Promise(function (resolve_2, reject_2) { require(["./1"], resolve_2, reject_2); })); + let one = await (__syncRequire ? Promise.resolve().then(function () { return require("./1"); }) : new Promise(function (resolve_3, reject_3) { require(["./1"], resolve_3, reject_3); })); console.log(one.backup()); }); } } + class D { + constructor() { + this.myModule = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_4, reject_4) { require(["./0"], resolve_4, reject_4); }); + } + method() { + const loadAsync = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_5, reject_5) { require(["./0"], resolve_5, reject_5); }); + this.myModule.then(Zero => { + console.log(Zero.foo()); + }, async (err) => { + console.log(err); + let one = await (__syncRequire ? Promise.resolve().then(function () { return require("./1"); }) : new Promise(function (resolve_6, reject_6) { require(["./1"], resolve_6, reject_6); })); + console.log(one.backup()); + }); + } + } + exports.D = D; }); diff --git a/tests/baselines/reference/importCallExpressionInUMD4.symbols b/tests/baselines/reference/importCallExpressionInUMD4.symbols index b02646d5e3d..c4de50e5bc4 100644 --- a/tests/baselines/reference/importCallExpressionInUMD4.symbols +++ b/tests/baselines/reference/importCallExpressionInUMD4.symbols @@ -27,35 +27,88 @@ class C { method() { >method : Symbol(C.method, Decl(2.ts, 2, 37)) + const loadAsync = import("./0"); +>loadAsync : Symbol(loadAsync, Decl(2.ts, 4, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + this.myModule.then(Zero => { >this.myModule.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) >this.myModule : Symbol(C.myModule, Decl(2.ts, 1, 9)) >this : Symbol(C, Decl(2.ts, 0, 25)) >myModule : Symbol(C.myModule, Decl(2.ts, 1, 9)) >then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) ->Zero : Symbol(Zero, Decl(2.ts, 4, 27)) +>Zero : Symbol(Zero, Decl(2.ts, 5, 27)) console.log(Zero.foo()); >console : Symbol(console, Decl(2.ts, 0, 11)) >Zero.foo : Symbol(foo, Decl(0.ts, 2, 1)) ->Zero : Symbol(Zero, Decl(2.ts, 4, 27)) +>Zero : Symbol(Zero, Decl(2.ts, 5, 27)) >foo : Symbol(foo, Decl(0.ts, 2, 1)) }, async err => { ->err : Symbol(err, Decl(2.ts, 6, 16)) +>err : Symbol(err, Decl(2.ts, 7, 16)) console.log(err); >console : Symbol(console, Decl(2.ts, 0, 11)) ->err : Symbol(err, Decl(2.ts, 6, 16)) +>err : Symbol(err, Decl(2.ts, 7, 16)) let one = await import("./1"); ->one : Symbol(one, Decl(2.ts, 8, 15)) +>one : Symbol(one, Decl(2.ts, 9, 15)) >"./1" : Symbol("tests/cases/conformance/dynamicImport/1", Decl(1.ts, 0, 0)) console.log(one.backup()); >console : Symbol(console, Decl(2.ts, 0, 11)) >one.backup : Symbol(backup, Decl(1.ts, 0, 0)) ->one : Symbol(one, Decl(2.ts, 8, 15)) +>one : Symbol(one, Decl(2.ts, 9, 15)) +>backup : Symbol(backup, Decl(1.ts, 0, 0)) + + }); + } +} + +export class D { +>D : Symbol(D, Decl(2.ts, 13, 1)) + + private myModule = import("./0"); +>myModule : Symbol(D.myModule, Decl(2.ts, 15, 16)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + + method() { +>method : Symbol(D.method, Decl(2.ts, 16, 37)) + + const loadAsync = import("./0"); +>loadAsync : Symbol(loadAsync, Decl(2.ts, 18, 13)) +>"./0" : Symbol("tests/cases/conformance/dynamicImport/0", Decl(0.ts, 0, 0)) + + this.myModule.then(Zero => { +>this.myModule.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>this.myModule : Symbol(D.myModule, Decl(2.ts, 15, 16)) +>this : Symbol(D, Decl(2.ts, 13, 1)) +>myModule : Symbol(D.myModule, Decl(2.ts, 15, 16)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Zero : Symbol(Zero, Decl(2.ts, 19, 27)) + + console.log(Zero.foo()); +>console : Symbol(console, Decl(2.ts, 0, 11)) +>Zero.foo : Symbol(foo, Decl(0.ts, 2, 1)) +>Zero : Symbol(Zero, Decl(2.ts, 19, 27)) +>foo : Symbol(foo, Decl(0.ts, 2, 1)) + + }, async err => { +>err : Symbol(err, Decl(2.ts, 21, 16)) + + console.log(err); +>console : Symbol(console, Decl(2.ts, 0, 11)) +>err : Symbol(err, Decl(2.ts, 21, 16)) + + let one = await import("./1"); +>one : Symbol(one, Decl(2.ts, 23, 15)) +>"./1" : Symbol("tests/cases/conformance/dynamicImport/1", Decl(1.ts, 0, 0)) + + console.log(one.backup()); +>console : Symbol(console, Decl(2.ts, 0, 11)) +>one.backup : Symbol(backup, Decl(1.ts, 0, 0)) +>one : Symbol(one, Decl(2.ts, 23, 15)) >backup : Symbol(backup, Decl(1.ts, 0, 0)) }); diff --git a/tests/baselines/reference/importCallExpressionInUMD4.types b/tests/baselines/reference/importCallExpressionInUMD4.types index 2ea666ba672..156247851c9 100644 --- a/tests/baselines/reference/importCallExpressionInUMD4.types +++ b/tests/baselines/reference/importCallExpressionInUMD4.types @@ -31,6 +31,78 @@ class C { method() { >method : () => void + const loadAsync = import("./0"); +>loadAsync : Promise +>import("./0") : Promise +>"./0" : "./0" + + this.myModule.then(Zero => { +>this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise +>this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>this.myModule : Promise +>this : this +>myModule : Promise +>then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void +>Zero : typeof "tests/cases/conformance/dynamicImport/0" + + console.log(Zero.foo()); +>console.log(Zero.foo()) : any +>console.log : any +>console : any +>log : any +>Zero.foo() : string +>Zero.foo : () => string +>Zero : typeof "tests/cases/conformance/dynamicImport/0" +>foo : () => string + + }, async err => { +>async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); } : (err: any) => Promise +>err : any + + console.log(err); +>console.log(err) : any +>console.log : any +>console : any +>log : any +>err : any + + let one = await import("./1"); +>one : typeof "tests/cases/conformance/dynamicImport/1" +>await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" +>import("./1") : Promise +>"./1" : "./1" + + console.log(one.backup()); +>console.log(one.backup()) : any +>console.log : any +>console : any +>log : any +>one.backup() : string +>one.backup : () => string +>one : typeof "tests/cases/conformance/dynamicImport/1" +>backup : () => string + + }); + } +} + +export class D { +>D : D + + private myModule = import("./0"); +>myModule : Promise +>import("./0") : Promise +>"./0" : "./0" + + method() { +>method : () => void + + const loadAsync = import("./0"); +>loadAsync : Promise +>import("./0") : Promise +>"./0" : "./0" + this.myModule.then(Zero => { >this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise >this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise diff --git a/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.errors.txt b/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.errors.txt index cf665dda049..b422869ff21 100644 --- a/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.errors.txt +++ b/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.errors.txt @@ -1,7 +1,8 @@ error TS2468: Cannot find global value 'Promise'. tests/cases/conformance/dynamicImport/2.ts(3,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option. -tests/cases/conformance/dynamicImport/2.ts(7,12): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option. -tests/cases/conformance/dynamicImport/2.ts(9,29): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option. +tests/cases/conformance/dynamicImport/2.ts(5,27): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option. +tests/cases/conformance/dynamicImport/2.ts(8,12): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option. +tests/cases/conformance/dynamicImport/2.ts(10,29): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option. !!! error TS2468: Cannot find global value 'Promise'. @@ -15,13 +16,16 @@ tests/cases/conformance/dynamicImport/2.ts(9,29): error TS2712: A dynamic import ==== tests/cases/conformance/dynamicImport/1.ts (0 errors) ==== export function backup() { return "backup"; } -==== tests/cases/conformance/dynamicImport/2.ts (3 errors) ==== +==== tests/cases/conformance/dynamicImport/2.ts (4 errors) ==== declare var console: any; class C { private myModule = import("./0"); ~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option. method() { + const loadAsync = import("./0"); + ~~~~~~~~~~~~~ +!!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option. this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { diff --git a/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.js b/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.js index 487d4e03a6c..598056a32c6 100644 --- a/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.js +++ b/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.js @@ -15,6 +15,7 @@ declare var console: any; class C { private myModule = import("./0"); method() { + const loadAsync = import("./0"); this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { @@ -84,6 +85,7 @@ var C = (function () { } C.prototype.method = function () { var _this = this; + var loadAsync = Promise.resolve().then(function () { return require("./0"); }); this.myModule.then(function (Zero) { console.log(Zero.foo()); }, function (err) { return __awaiter(_this, void 0, void 0, function () { diff --git a/tests/baselines/reference/importCallExpressionWithTypeArgument.errors.txt b/tests/baselines/reference/importCallExpressionWithTypeArgument.errors.txt index 8adf2789585..34c423a0d2f 100644 --- a/tests/baselines/reference/importCallExpressionWithTypeArgument.errors.txt +++ b/tests/baselines/reference/importCallExpressionWithTypeArgument.errors.txt @@ -12,7 +12,4 @@ tests/cases/conformance/dynamicImport/1.ts(3,10): error TS1326: Dynamic import c !!! error TS1326: Dynamic import cannot have type arguments var p2 = import<>("./0"); // error ~~~~~~~~~~~~~~~ -!!! error TS1326: Dynamic import cannot have type arguments - // p1.then(value => { - // value.anyFunction(); - // }) \ No newline at end of file +!!! error TS1326: Dynamic import cannot have type arguments \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionWithTypeArgument.js b/tests/baselines/reference/importCallExpressionWithTypeArgument.js index d8690cf5d75..b98d039fd26 100644 --- a/tests/baselines/reference/importCallExpressionWithTypeArgument.js +++ b/tests/baselines/reference/importCallExpressionWithTypeArgument.js @@ -6,10 +6,7 @@ export function foo() { return "foo"; } //// [1.ts] "use strict" var p1 = import>("./0"); // error -var p2 = import<>("./0"); // error -// p1.then(value => { -// value.anyFunction(); -// }) +var p2 = import<>("./0"); // error //// [0.js] "use strict";