mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-26 19:39:23 -05:00
fix(52177): Wrong space in type assertions when using array (#52184)
This commit is contained in:
@@ -240,11 +240,12 @@ export function getAllRules(): RuleSpec[] {
|
||||
rule("NoSpaceBetweenCloseParenAndAngularBracket", SyntaxKind.CloseParenToken, SyntaxKind.LessThanToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], RuleAction.DeleteSpace),
|
||||
rule("NoSpaceAfterOpenAngularBracket", SyntaxKind.LessThanToken, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], RuleAction.DeleteSpace),
|
||||
rule("NoSpaceBeforeCloseAngularBracket", anyToken, SyntaxKind.GreaterThanToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], RuleAction.DeleteSpace),
|
||||
rule("NoSpaceAfterCloseAngularBracket",
|
||||
SyntaxKind.GreaterThanToken,
|
||||
[SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken, SyntaxKind.GreaterThanToken, SyntaxKind.CommaToken],
|
||||
[isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/],
|
||||
RuleAction.DeleteSpace),
|
||||
rule("NoSpaceAfterCloseAngularBracket", SyntaxKind.GreaterThanToken, [SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken, SyntaxKind.GreaterThanToken, SyntaxKind.CommaToken], [
|
||||
isNonJsxSameLineTokenContext,
|
||||
isTypeArgumentOrParameterOrAssertionContext,
|
||||
isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/,
|
||||
isNonTypeAssertionContext
|
||||
], RuleAction.DeleteSpace),
|
||||
|
||||
// decorators
|
||||
rule("SpaceBeforeAt", [SyntaxKind.CloseParenToken, SyntaxKind.Identifier], SyntaxKind.AtToken, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace),
|
||||
@@ -835,6 +836,10 @@ function isTypeAssertionContext(context: FormattingContext): boolean {
|
||||
return context.contextNode.kind === SyntaxKind.TypeAssertionExpression;
|
||||
}
|
||||
|
||||
function isNonTypeAssertionContext(context: FormattingContext): boolean {
|
||||
return !isTypeAssertionContext(context);
|
||||
}
|
||||
|
||||
function isVoidOpContext(context: FormattingContext): boolean {
|
||||
return context.currentTokenSpan.kind === SyntaxKind.VoidKeyword && context.currentTokenParent.kind === SyntaxKind.VoidExpression;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user