Forbid non-null assertion in '.js' files (#17481)

This commit is contained in:
Andy
2017-07-28 16:40:20 -07:00
committed by GitHub
parent 58769e1dab
commit 2efaa7c9e2
5 changed files with 27 additions and 0 deletions

View File

@@ -16384,6 +16384,10 @@ namespace ts {
}
function checkNonNullAssertion(node: NonNullExpression) {
if (isInJavaScriptFile(node)) {
error(node, Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file);
}
return getNonNullableType(checkExpression(node.expression));
}

View File

@@ -3459,6 +3459,10 @@
"category": "Error",
"code": 8012
},
"'non-null assertions' can only be used in a .ts file.": {
"category": "Error",
"code": 8013
},
"'enum declarations' can only be used in a .ts file.": {
"category": "Error",
"code": 8015