Remove error with noImplicitAny

This commit is contained in:
Kanchalai Tanglertsampan 2017-03-28 12:38:41 -07:00
parent 486dc91f76
commit 6080c3efd6
4 changed files with 7 additions and 29 deletions

View File

@ -284,7 +284,6 @@ namespace ts {
let deferredGlobalAsyncIterableIteratorType: GenericType;
let deferredGlobalTemplateStringsArrayType: ObjectType;
let deferredJsxElementClassType: Type;
let deferredGlobalPromiseAnyType: Type;
let deferredNodes: Node[];
let deferredUnusedIdentifierNodes: Node[];
@ -3456,11 +3455,6 @@ namespace ts {
// Use the type of the initializer expression if one is present
if (declaration.initializer) {
const type = checkDeclarationInitializer(declaration);
if (isImportCall(declaration.initializer)) {
if (noImplicitAny && type === getGlobalPromiseAnyType()) {
error(declaration, Diagnostics.Cannot_resolve_dynamic_import_implicitly_has_a_Promise_any_type); }
}
return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality);
}
@ -6089,10 +6083,6 @@ namespace ts {
return deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", /*arity*/ 1, reportErrors)) || emptyGenericType;
}
function getGlobalPromiseAnyType() {
return deferredGlobalPromiseAnyType || (deferredGlobalPromiseAnyType = createPromiseType(anyType));
}
function getGlobalPromiseConstructorSymbol(reportErrors: boolean): Symbol | undefined {
return deferredGlobalPromiseConstructorSymbol || (deferredGlobalPromiseConstructorSymbol = getGlobalValueSymbol("Promise", reportErrors));
}

View File

@ -1,4 +1,4 @@
{
{
"Unterminated string literal.": {
"category": "Error",
"code": 1002
@ -3174,14 +3174,11 @@
"category": "Error",
"code": 7034
},
"Cannot resolve dynamic import, implicitly has a 'Promise<any>' type.": {
"category": "Error",
"code": 7035
},
"Dynamic import's specifier must be of type 'string', but here has type '{0}'.": {
"category": "Error",
"code": 7036
"category": "Error",
"code": 7035
},
"You cannot rename this element.": {
"category": "Error",
"code": 8000

View File

@ -1,12 +0,0 @@
// @module: es2018
// @target: esnext
// @filename: 0.ts
// @noImplicitAny: true
// @filename: 1.ts
declare function ValidSomeCondition(): boolean;
import(ValidSomeCondition() ? "./0" : "externalModule"); // implicit any error
var p1 = import(ValidSomeCondition() ? "./0" : "externalModule"); // implicit any error
p1.then(zero => {
return zero.foo(); // ok
});

View File

@ -7,12 +7,15 @@ export class C {}
// @filename: 1.ts
import * as defaultModule from "./defaultPath";
declare function getSpecifier(): string;
declare function ValidSomeCondition(): boolean;
declare var whatToLoad: boolean;
declare const directory: string;
declare const moduleFile: number;
import(`${directory}\${moduleFile}`);
import(getSpecifier());
var p1 = import(ValidSomeCondition() ? "./0" : "externalModule");
var p1: Promise<any> = import(getSpecifier());
var p11: Promise<typeof defaultModule> = import(getSpecifier());
const p2 = import(whatToLoad ? getSpecifier() : "defaulPath") as Promise<typeof defaultModule>;