Skip to content

Commit 6080c3e

Browse files
author
Kanchalai Tanglertsampan
committed
Remove error with noImplicitAny
1 parent 486dc91 commit 6080c3e

4 files changed

Lines changed: 7 additions & 29 deletions

File tree

src/compiler/checker.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ namespace ts {
284284
let deferredGlobalAsyncIterableIteratorType: GenericType;
285285
let deferredGlobalTemplateStringsArrayType: ObjectType;
286286
let deferredJsxElementClassType: Type;
287-
let deferredGlobalPromiseAnyType: Type;
288287

289288
let deferredNodes: Node[];
290289
let deferredUnusedIdentifierNodes: Node[];
@@ -3456,11 +3455,6 @@ namespace ts {
34563455
// Use the type of the initializer expression if one is present
34573456
if (declaration.initializer) {
34583457
const type = checkDeclarationInitializer(declaration);
3459-
3460-
if (isImportCall(declaration.initializer)) {
3461-
if (noImplicitAny && type === getGlobalPromiseAnyType()) {
3462-
error(declaration, Diagnostics.Cannot_resolve_dynamic_import_implicitly_has_a_Promise_any_type); }
3463-
}
34643458
return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality);
34653459
}
34663460

@@ -6089,10 +6083,6 @@ namespace ts {
60896083
return deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", /*arity*/ 1, reportErrors)) || emptyGenericType;
60906084
}
60916085

6092-
function getGlobalPromiseAnyType() {
6093-
return deferredGlobalPromiseAnyType || (deferredGlobalPromiseAnyType = createPromiseType(anyType));
6094-
}
6095-
60966086
function getGlobalPromiseConstructorSymbol(reportErrors: boolean): Symbol | undefined {
60976087
return deferredGlobalPromiseConstructorSymbol || (deferredGlobalPromiseConstructorSymbol = getGlobalValueSymbol("Promise", reportErrors));
60986088
}

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"Unterminated string literal.": {
33
"category": "Error",
44
"code": 1002
@@ -3174,14 +3174,11 @@
31743174
"category": "Error",
31753175
"code": 7034
31763176
},
3177-
"Cannot resolve dynamic import, implicitly has a 'Promise<any>' type.": {
3178-
"category": "Error",
3179-
"code": 7035
3180-
},
31813177
"Dynamic import's specifier must be of type 'string', but here has type '{0}'.": {
3182-
"category": "Error",
3183-
"code": 7036
3178+
"category": "Error",
3179+
"code": 7035
31843180
},
3181+
31853182
"You cannot rename this element.": {
31863183
"category": "Error",
31873184
"code": 8000

tests/cases/conformance/es2018/dynamicImport/importCallExpressionNoImplicitAnyError.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/cases/conformance/es2018/dynamicImport/importCallExpressionReturnPromiseOfAny.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ export class C {}
77
// @filename: 1.ts
88
import * as defaultModule from "./defaultPath";
99
declare function getSpecifier(): string;
10+
declare function ValidSomeCondition(): boolean;
1011
declare var whatToLoad: boolean;
1112
declare const directory: string;
1213
declare const moduleFile: number;
1314

1415
import(`${directory}\${moduleFile}`);
1516
import(getSpecifier());
17+
18+
var p1 = import(ValidSomeCondition() ? "./0" : "externalModule");
1619
var p1: Promise<any> = import(getSpecifier());
1720
var p11: Promise<typeof defaultModule> = import(getSpecifier());
1821
const p2 = import(whatToLoad ? getSpecifier() : "defaulPath") as Promise<typeof defaultModule>;

0 commit comments

Comments
 (0)