Skip to content

Commit e6d7327

Browse files
author
Yui T
committed
Address PR: error message, fix capitalization, only allow functionLikeDeclaration and ImportCall for create Promise, use fall through comment
1 parent 72ba23c commit e6d7327

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16332,11 +16332,11 @@ namespace ts {
1633216332
return emptyObjectType;
1633316333
}
1633416334

16335-
function createPromiseReturnType(func: FunctionLikeDeclaration | CallExpression, promisedType: Type) {
16335+
function createPromiseReturnType(func: FunctionLikeDeclaration | ImportCall, promisedType: Type) {
1633616336
const promiseType = createPromiseType(promisedType);
1633716337
if (promiseType === emptyObjectType) {
1633816338
error(func, isImportCall(func) ?
16339-
Diagnostics.A_dynamic_import_call_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option :
16339+
Diagnostics.A_dynamic_import_call_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option :
1634016340
Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option);
1634116341
return unknownType;
1634216342
}
@@ -17705,7 +17705,7 @@ namespace ts {
1770517705
if ((<CallExpression>node).expression.kind === SyntaxKind.ImportKeyword) {
1770617706
return checkImportCallExpression(<ImportCall>node);
1770717707
}
17708-
/* tslint:disable: no-switch-case-fall-through */
17708+
/* falls through */
1770917709
case SyntaxKind.NewExpression:
1771017710
return checkCallExpression(<CallExpression>node);
1771117711
case SyntaxKind.TaggedTemplateExpression:

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2172,7 +2172,7 @@
21722172
"category": "Error",
21732173
"code": 2710
21742174
},
2175-
"A dynamic import call must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option.": {
2175+
"A dynamic import call return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option.": {
21762176
"category": "Error",
21772177
"code": 2711
21782178
},

src/compiler/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3700,7 +3700,7 @@ namespace ts {
37003700
// For example:
37013701
// var foo3 = require("subfolder
37023702
// import * as foo1 from "module-from-node -> we want this import to be a statement rather than import call expression
3703-
sourceFile.flags |= NodeFlags.possiblyContainDynamicImport;
3703+
sourceFile.flags |= NodeFlags.PossiblyContainDynamicImport;
37043704
expression = parseTokenNode<PrimaryExpression>();
37053705
}
37063706
else {

src/compiler/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,7 @@ namespace ts {
13831383

13841384
for (const node of file.statements) {
13851385
collectModuleReferences(node, /*inAmbientModule*/ false);
1386-
if ((file.flags & NodeFlags.possiblyContainDynamicImport) || isJavaScriptFile) {
1386+
if ((file.flags & NodeFlags.PossiblyContainDynamicImport) || isJavaScriptFile) {
13871387
collectDynamicImportOrRequireCalls(node);
13881388
}
13891389
}

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ namespace ts {
456456
// During editing, if dynamic import is remove, incremental parsing will *NOT* update this flag. This will then causes walking of the tree during module resolution.
457457
// However, the removal operation should not occur often and in the case of the removal, it is likely that users will add back the import anyway.
458458
// The advantage of this approach is its simplicity. For the case of batch compilation, we garuntee that users won't have to pay the price of walking the tree if dynamic import isn't used.
459-
possiblyContainDynamicImport = 1 << 19,
459+
PossiblyContainDynamicImport = 1 << 19,
460460

461461
BlockScoped = Let | Const,
462462

0 commit comments

Comments
 (0)