mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Move grammar checking: Arrow function
This commit is contained in:
@@ -6992,7 +6992,10 @@ module ts {
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
return checkExpression((<ParenthesizedExpression>node).expression);
|
||||
case SyntaxKind.FunctionExpression:
|
||||
return checkFunctionExpressionOrObjectLiteralMethod(<FunctionExpression>node, contextualMapper);
|
||||
case SyntaxKind.ArrowFunction:
|
||||
// Grammar checking
|
||||
checkGrammarSignatureDeclarationOrArrowFunction(<FunctionExpression>node);
|
||||
return checkFunctionExpressionOrObjectLiteralMethod(<FunctionExpression>node, contextualMapper);
|
||||
case SyntaxKind.TypeOfExpression:
|
||||
return checkTypeOfExpression(<TypeOfExpression>node);
|
||||
@@ -8755,7 +8758,7 @@ module ts {
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
// Grammar checking
|
||||
checkGrammarSignatureDeclaration(<SignatureDeclaration>node)
|
||||
checkGrammarSignatureDeclarationOrArrowFunction(<SignatureDeclaration>node)
|
||||
return checkSignatureDeclaration(<SignatureDeclaration>node);
|
||||
case SyntaxKind.IndexSignature:
|
||||
// Grammar checking
|
||||
@@ -9767,7 +9770,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkGrammarTypeParameterList(signatureDecl: SignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration>): boolean {
|
||||
function checkGrammarTypeParameterList(signatureDecl: SignatureDeclaration | Expression, typeParameters: NodeArray<TypeParameterDeclaration>): boolean {
|
||||
if (checkGrammarForDisallowedTrailingComma(typeParameters)) {
|
||||
return true;
|
||||
}
|
||||
@@ -9818,9 +9821,9 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkGrammarSignatureDeclaration(node: SignatureDeclaration) {
|
||||
if (!checkGrammarTypeParameterList(node, node.typeParameters)) {
|
||||
checkGrammarParameterList(node.parameters);
|
||||
function checkGrammarSignatureDeclarationOrArrowFunction(node: SignatureDeclaration | FunctionExpression) {
|
||||
if (!checkGrammarTypeParameterList(node, (<SignatureDeclaration>node).typeParameters)) {
|
||||
checkGrammarParameterList((<SignatureDeclaration>node).parameters);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ module ts {
|
||||
_0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element.", isEarly: true },
|
||||
A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." },
|
||||
A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." },
|
||||
A_rest_parameter_cannot_be_optional: { code: 1047, category: DiagnosticCategory.Error, key: "A rest parameter cannot be optional." },
|
||||
A_rest_parameter_cannot_be_optional: { code: 1047, category: DiagnosticCategory.Error, key: "A rest parameter cannot be optional.", isEarly: true },
|
||||
A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." },
|
||||
A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: DiagnosticCategory.Error, key: "A 'set' accessor must have exactly one parameter." },
|
||||
A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have an optional parameter." },
|
||||
|
||||
@@ -166,7 +166,8 @@
|
||||
},
|
||||
"A rest parameter cannot be optional.": {
|
||||
"category": "Error",
|
||||
"code": 1047
|
||||
"code": 1047,
|
||||
"isEarly": true
|
||||
},
|
||||
"A rest parameter cannot have an initializer.": {
|
||||
"category": "Error",
|
||||
|
||||
@@ -4626,8 +4626,6 @@ module ts {
|
||||
function checkNode(node: Node, nodeKind: SyntaxKind): boolean {
|
||||
// Now do node specific checks.
|
||||
switch (nodeKind) {
|
||||
case SyntaxKind.ArrowFunction:
|
||||
return checkAnySignatureDeclaration(<FunctionLikeDeclaration>node);
|
||||
case SyntaxKind.BreakStatement:
|
||||
case SyntaxKind.ContinueStatement:
|
||||
return checkBreakOrContinueStatement(<BreakOrContinueStatement>node);
|
||||
|
||||
Reference in New Issue
Block a user