Merge pull request #19317 from igelbox/fix-insert-space-after-function-generic

Fixed incorrect insertSpaceBeforeFunctionParenthesis behavior on funtions with type-arguments
This commit is contained in:
Mohamed Hegazy
2018-04-03 16:11:30 -07:00
committed by GitHub
3 changed files with 13 additions and 3 deletions

View File

@@ -198,7 +198,7 @@ namespace ts.formatting {
rule("NoSpaceAfterCloseAngularBracket",
SyntaxKind.GreaterThanToken,
[SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken, SyntaxKind.GreaterThanToken, SyntaxKind.CommaToken],
[isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext],
[isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/],
RuleAction.Delete),
// decorators
@@ -542,6 +542,10 @@ namespace ts.formatting {
return false;
}
function isNotFunctionDeclContext(context: FormattingContext): boolean {
return !isFunctionDeclContext(context);
}
function isFunctionDeclarationOrFunctionExpressionContext(context: FormattingContext): boolean {
return context.contextNode.kind === SyntaxKind.FunctionDeclaration || context.contextNode.kind === SyntaxKind.FunctionExpression;
}