fix(46433): forbid using keywords as parameter names (#46459)

This commit is contained in:
Oleksandr T
2021-10-22 19:58:01 +03:00
committed by GitHub
parent 449aaa118f
commit ce676d0963
12 changed files with 124 additions and 6 deletions

View File

@@ -1164,6 +1164,10 @@
"category": "Error",
"code": 1389
},
"'{0}' is not allowed as a parameter name.": {
"category": "Error",
"code": 1390
},
"An import alias cannot use 'import type'": {
"category": "Error",
"code": 1392

View File

@@ -2611,7 +2611,10 @@ namespace ts {
case ParsingContext.ObjectLiteralMembers: return parseErrorAtCurrentToken(Diagnostics.Property_assignment_expected);
case ParsingContext.ArrayLiteralMembers: return parseErrorAtCurrentToken(Diagnostics.Expression_or_comma_expected);
case ParsingContext.JSDocParameters: return parseErrorAtCurrentToken(Diagnostics.Parameter_declaration_expected);
case ParsingContext.Parameters: return parseErrorAtCurrentToken(Diagnostics.Parameter_declaration_expected);
case ParsingContext.Parameters:
return isKeyword(token())
? parseErrorAtCurrentToken(Diagnostics._0_is_not_allowed_as_a_parameter_name, tokenToString(token()))
: parseErrorAtCurrentToken(Diagnostics.Parameter_declaration_expected);
case ParsingContext.TypeParameters: return parseErrorAtCurrentToken(Diagnostics.Type_parameter_declaration_expected);
case ParsingContext.TypeArguments: return parseErrorAtCurrentToken(Diagnostics.Type_argument_expected);
case ParsingContext.TupleElementTypes: return parseErrorAtCurrentToken(Diagnostics.Type_expected);