From 4bc8bbdeea576b78137c75e5d296e64f610d2a59 Mon Sep 17 00:00:00 2001 From: steinuil Date: Fri, 11 Jan 2019 17:15:19 +0100 Subject: [PATCH] trailing-comma: check for a closing parenthesis fixes #4456 --- src/rules/trailingCommaRule.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/rules/trailingCommaRule.ts b/src/rules/trailingCommaRule.ts index ce2668a60d6..941122c1197 100644 --- a/src/rules/trailingCommaRule.ts +++ b/src/rules/trailingCommaRule.ts @@ -229,12 +229,19 @@ class TrailingCommaWalker extends Lint.AbstractWalker { case ts.SyntaxKind.ConstructorType: case ts.SyntaxKind.FunctionType: case ts.SyntaxKind.CallSignature: - this.checkList( - (node as ts.SignatureDeclaration).parameters, - getChildOfKind(node, ts.SyntaxKind.CloseParenToken, this.sourceFile)!.end, - "functions", - isRestParameter, + const closingParen = getChildOfKind( + node, + ts.SyntaxKind.CloseParenToken, + this.sourceFile, ); + if (closingParen !== undefined) { + this.checkList( + (node as ts.SignatureDeclaration).parameters, + closingParen.end, + "functions", + isRestParameter, + ); + } break; case ts.SyntaxKind.TypeLiteral: this.checkTypeLiteral(node as ts.TypeLiteralNode);