Skip to content

Commit c404666

Browse files
authored
Merge pull request microsoft#14365 from Microsoft/master-fix14259
[Master] Fix 14259 : remove assertion
2 parents fc9bcc1 + 4aac67b commit c404666

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

src/compiler/checker.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -14804,7 +14804,6 @@ namespace ts {
1480414804

1480514805
function checkMetaProperty(node: MetaProperty) {
1480614806
checkGrammarMetaProperty(node);
14807-
Debug.assert(node.keywordToken === SyntaxKind.NewKeyword && node.name.text === "target", "Unrecognized meta-property.");
1480814807
const container = getNewTargetContainer(node);
1480914808
if (!container) {
1481014809
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 {
2302123020
function checkGrammarMetaProperty(node: MetaProperty) {
2302223021
if (node.keywordToken === SyntaxKind.NewKeyword) {
2302323022
if (node.name.text !== "target") {
23024-
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");
23023+
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");
2302523024
}
2302623025
}
2302723026
}

src/compiler/diagnosticMessages.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3269,7 +3269,7 @@
32693269
"category": "Error",
32703270
"code": 17011
32713271
},
3272-
"'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?": {
3272+
"'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{2}'?": {
32733273
"category": "Error",
32743274
"code": 17012
32753275
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
tests/cases/compiler/misspelledNewMetaProperty.ts(1,20): error TS17012: 'targ' is not a valid meta-property for keyword 'new'. Did you mean 'target'?
2+
3+
4+
==== tests/cases/compiler/misspelledNewMetaProperty.ts (1 errors) ====
5+
function foo(){new.targ}
6+
~~~~
7+
!!! error TS17012: 'targ' is not a valid meta-property for keyword 'new'. Did you mean 'target'?
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//// [misspelledNewMetaProperty.ts]
2+
function foo(){new.targ}
3+
4+
//// [misspelledNewMetaProperty.js]
5+
function foo() { new.targ; }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
function foo(){new.targ}

0 commit comments

Comments
 (0)