Remove assertion

This commit is contained in:
Kanchalai Tanglertsampan
2017-02-28 09:59:17 -08:00
parent fc9bcc1d8f
commit 4aac67b4e6
5 changed files with 15 additions and 3 deletions

View File

@@ -14804,7 +14804,6 @@ namespace ts {
function checkMetaProperty(node: MetaProperty) {
checkGrammarMetaProperty(node);
Debug.assert(node.keywordToken === SyntaxKind.NewKeyword && node.name.text === "target", "Unrecognized meta-property.");
const container = getNewTargetContainer(node);
if (!container) {
error(node, Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target");
@@ -23021,7 +23020,7 @@ namespace ts {
function checkGrammarMetaProperty(node: MetaProperty) {
if (node.keywordToken === SyntaxKind.NewKeyword) {
if (node.name.text !== "target") {
return grammarErrorOnNode(node.name, Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, tokenToString(node.keywordToken), "target");
return grammarErrorOnNode(node.name, Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.text, tokenToString(node.keywordToken), "target");
}
}
}

View File

@@ -3269,7 +3269,7 @@
"category": "Error",
"code": 17011
},
"'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?": {
"'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{2}'?": {
"category": "Error",
"code": 17012
},

View File

@@ -0,0 +1,7 @@
tests/cases/compiler/misspelledNewMetaProperty.ts(1,20): error TS17012: 'targ' is not a valid meta-property for keyword 'new'. Did you mean 'target'?
==== tests/cases/compiler/misspelledNewMetaProperty.ts (1 errors) ====
function foo(){new.targ}
~~~~
!!! error TS17012: 'targ' is not a valid meta-property for keyword 'new'. Did you mean 'target'?

View File

@@ -0,0 +1,5 @@
//// [misspelledNewMetaProperty.ts]
function foo(){new.targ}
//// [misspelledNewMetaProperty.js]
function foo() { new.targ; }

View File

@@ -0,0 +1 @@
function foo(){new.targ}