mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
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:
commit
db74229a89
@ -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;
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
/////*2*/function boo () { }
|
||||
/////*3*/var bar = function foo() { };
|
||||
/////*4*/var foo = { bar() { } };
|
||||
/////*5*/function tmpl <T> () { }
|
||||
|
||||
format.setOption("InsertSpaceBeforeFunctionParenthesis", true);
|
||||
|
||||
@ -16,4 +17,6 @@ verify.currentLineContentIs('function boo () { }');
|
||||
goTo.marker('3');
|
||||
verify.currentLineContentIs('var bar = function foo () { };');
|
||||
goTo.marker('4');
|
||||
verify.currentLineContentIs('var foo = { bar () { } };');
|
||||
verify.currentLineContentIs('var foo = { bar () { } };');
|
||||
goTo.marker('5');
|
||||
verify.currentLineContentIs('function tmpl<T> () { }');
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
////foo()<number, string, T >();
|
||||
////(a + b)<number, string, T >();
|
||||
////
|
||||
////function bar<T>() {
|
||||
/////*inFunctionDeclaration*/function bar <T> () {
|
||||
/////*inClassExpression*/ return class < T2 > {
|
||||
//// }
|
||||
////}
|
||||
@ -42,6 +42,9 @@ verify.currentLineContentIs(" new <T>(a: T);");
|
||||
goTo.marker("inOptionalMethodSignature");
|
||||
verify.currentLineContentIs(" op?<T, M>(a: T, b: M);");
|
||||
|
||||
goTo.marker("inFunctionDeclaration");
|
||||
verify.currentLineContentIs("function bar<T>() {");
|
||||
|
||||
goTo.marker("inClassExpression");
|
||||
verify.currentLineContentIs(" return class <T2> {");
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user