From 5cb958ef43c4b3c1a8d2d474b8fa858b5111610b Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 15 Dec 2014 17:16:22 -0800 Subject: [PATCH] Address code review --- src/compiler/checker.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 746061c008a..349f3766be6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7157,7 +7157,8 @@ module ts { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.ConstructorType || node.kind === SyntaxKind.CallSignature){ + else if (node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.ConstructorType || + node.kind === SyntaxKind.CallSignature || node.kind === SyntaxKind.Constructor){ checkGrammarFunctionLikeDeclaration(node); } @@ -7240,10 +7241,11 @@ module ts { } function checkConstructorDeclaration(node: ConstructorDeclaration) { - // Grammar check on signature of constructor is done in checkSignatureDeclaration function - checkGrammarModifiers(node) || checkGrammarFunctionLikeDeclaration(node) || checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node) || checkGrammarForBodyInAmbientContext(node.body, /*isConstructor:*/ true); - + // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. checkSignatureDeclaration(node); + // Grammar check for checking only related to constructoDeclaration + checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node) || checkGrammarForBodyInAmbientContext(node.body, /*isConstructor:*/ true); + checkSourceElement(node.body); var symbol = getSymbolOfNode(node); @@ -8178,7 +8180,7 @@ module ts { } else { // Grammar checking for invalid use of return statement - forEachReturnStatement(node.statement, (returnStatement) => { + forEachReturnStatement(node.statement, returnStatement => { grammarErrorOnFirstToken(returnStatement, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); }); }