Report an error if dynamic import specifier is not assigable to type string

This commit is contained in:
Kanchalai Tanglertsampan
2017-03-21 15:08:00 -07:00
parent f04f7b5afd
commit 871d6095ef
2 changed files with 8 additions and 0 deletions

View File

@@ -14873,6 +14873,10 @@ namespace ts {
grammarErrorOnNode(node, Diagnostics.Dynamic_import_cannot_be_used_when_targeting_ECMAScript_2015_modules);
}
const specifierType = checkExpression(node.specifier);
if (!isTypeAssignableTo(specifierType, stringType)) {
error(node.specifier, Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType));
}
// resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal
const moduleSymbol = resolveExternalModuleName(node, node.specifier);
if (moduleSymbol) {

View File

@@ -3165,6 +3165,10 @@
"category": "Error",
"code": 7035
},
"Dynamic import's specifier must be of type 'string', but here has type '{0}'.": {
"category": "Error",
"code": 7036
},
"You cannot rename this element.": {
"category": "Error",
"code": 8000