diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 73b586e3706..23c835eaec2 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -458,7 +458,11 @@ module ts.formatting { case SyntaxKind.BinaryExpression: case SyntaxKind.ConditionalExpression: return true; - + + // equals in binding elements: function foo([[x, y] = [1, 2]]) + case SyntaxKind.BindingElement: + // equals in type X = ... + case SyntaxKind.TypeAliasDeclaration: // equal in import a = module('a'); case SyntaxKind.ImportEqualsDeclaration: // equal in let a = 0; @@ -475,8 +479,6 @@ module ts.formatting { // Technically, "of" is not a binary operator, but format it the same way as "in" case SyntaxKind.ForOfStatement: return context.currentTokenSpan.kind === SyntaxKind.OfKeyword || context.nextTokenSpan.kind === SyntaxKind.OfKeyword; - case SyntaxKind.BindingElement: - return context.currentTokenSpan.kind === SyntaxKind.EqualsToken || context.nextTokenSpan.kind === SyntaxKind.EqualsToken; } return false; } diff --git a/tests/cases/fourslash/formattingEqualsBeforeBracketInTypeAlias.ts b/tests/cases/fourslash/formattingEqualsBeforeBracketInTypeAlias.ts new file mode 100644 index 00000000000..043ff2247a9 --- /dev/null +++ b/tests/cases/fourslash/formattingEqualsBeforeBracketInTypeAlias.ts @@ -0,0 +1,6 @@ +/// + +////type X = [number]/*1*/ +goTo.marker("1"); +edit.insert(";"); +verify.currentLineContentIs("type X = [number];"); \ No newline at end of file