Skip to content

Commit 1c93531

Browse files
authored
Merge pull request #17025 from Microsoft/master-16763
[Master] Fix 16763
2 parents 2368847 + f15909b commit 1c93531

File tree

6 files changed

+98
-2
lines changed

6 files changed

+98
-2
lines changed

src/compiler/utilities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5121,6 +5121,7 @@ namespace ts {
51215121
|| kind === SyntaxKind.ThisKeyword
51225122
|| kind === SyntaxKind.TrueKeyword
51235123
|| kind === SyntaxKind.SuperKeyword
5124+
|| kind === SyntaxKind.ImportKeyword
51245125
|| kind === SyntaxKind.NonNullExpression
51255126
|| kind === SyntaxKind.MetaProperty;
51265127
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//// [importCallExpressionShouldNotGetParen.ts]
2+
const localeName = "zh-CN";
3+
import(`./locales/${localeName}.js`).then(bar => {
4+
let x = bar;
5+
});
6+
7+
import("./locales/" + localeName + ".js").then(bar => {
8+
let x = bar;
9+
});
10+
11+
//// [importCallExpressionShouldNotGetParen.js]
12+
const localeName = "zh-CN";
13+
import(`./locales/${localeName}.js`).then(bar => {
14+
let x = bar;
15+
});
16+
import("./locales/" + localeName + ".js").then(bar => {
17+
let x = bar;
18+
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
=== tests/cases/conformance/dynamicImport/importCallExpressionShouldNotGetParen.ts ===
2+
const localeName = "zh-CN";
3+
>localeName : Symbol(localeName, Decl(importCallExpressionShouldNotGetParen.ts, 0, 5))
4+
5+
import(`./locales/${localeName}.js`).then(bar => {
6+
>import(`./locales/${localeName}.js`).then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
7+
>localeName : Symbol(localeName, Decl(importCallExpressionShouldNotGetParen.ts, 0, 5))
8+
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
9+
>bar : Symbol(bar, Decl(importCallExpressionShouldNotGetParen.ts, 1, 42))
10+
11+
let x = bar;
12+
>x : Symbol(x, Decl(importCallExpressionShouldNotGetParen.ts, 2, 7))
13+
>bar : Symbol(bar, Decl(importCallExpressionShouldNotGetParen.ts, 1, 42))
14+
15+
});
16+
17+
import("./locales/" + localeName + ".js").then(bar => {
18+
>import("./locales/" + localeName + ".js").then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
19+
>localeName : Symbol(localeName, Decl(importCallExpressionShouldNotGetParen.ts, 0, 5))
20+
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
21+
>bar : Symbol(bar, Decl(importCallExpressionShouldNotGetParen.ts, 5, 47))
22+
23+
let x = bar;
24+
>x : Symbol(x, Decl(importCallExpressionShouldNotGetParen.ts, 6, 7))
25+
>bar : Symbol(bar, Decl(importCallExpressionShouldNotGetParen.ts, 5, 47))
26+
27+
});
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
=== tests/cases/conformance/dynamicImport/importCallExpressionShouldNotGetParen.ts ===
2+
const localeName = "zh-CN";
3+
>localeName : "zh-CN"
4+
>"zh-CN" : "zh-CN"
5+
6+
import(`./locales/${localeName}.js`).then(bar => {
7+
>import(`./locales/${localeName}.js`).then(bar => { let x = bar;}) : Promise<void>
8+
>import(`./locales/${localeName}.js`).then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
9+
>import(`./locales/${localeName}.js`) : Promise<any>
10+
>`./locales/${localeName}.js` : string
11+
>localeName : "zh-CN"
12+
>then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
13+
>bar => { let x = bar;} : (bar: any) => void
14+
>bar : any
15+
16+
let x = bar;
17+
>x : any
18+
>bar : any
19+
20+
});
21+
22+
import("./locales/" + localeName + ".js").then(bar => {
23+
>import("./locales/" + localeName + ".js").then(bar => { let x = bar;}) : Promise<void>
24+
>import("./locales/" + localeName + ".js").then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
25+
>import("./locales/" + localeName + ".js") : Promise<any>
26+
>"./locales/" + localeName + ".js" : string
27+
>"./locales/" + localeName : string
28+
>"./locales/" : "./locales/"
29+
>localeName : "zh-CN"
30+
>".js" : ".js"
31+
>then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
32+
>bar => { let x = bar;} : (bar: any) => void
33+
>bar : any
34+
35+
let x = bar;
36+
>x : any
37+
>bar : any
38+
39+
});

tests/baselines/reference/importCallExpressionWithTypeArgument.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ function foo() { return "foo"; }
1818
exports.foo = foo;
1919
//// [1.js]
2020
"use strict";
21-
var p1 = (import)("./0"); // error
22-
var p2 = (import)("./0"); // error
21+
var p1 = Promise.resolve().then(function () { return require("./0"); }); // error
22+
var p2 = Promise.resolve().then(function () { return require("./0"); }); // error
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @module: esnext
2+
// @target: es6
3+
// @noImplicitAny: true
4+
const localeName = "zh-CN";
5+
import(`./locales/${localeName}.js`).then(bar => {
6+
let x = bar;
7+
});
8+
9+
import("./locales/" + localeName + ".js").then(bar => {
10+
let x = bar;
11+
});

0 commit comments

Comments
 (0)