diff --git a/changelog_unreleased/typescript/18094.md b/changelog_unreleased/typescript/18094.md index 7cdabf4c1..4dab2cb52 100644 --- a/changelog_unreleased/typescript/18094.md +++ b/changelog_unreleased/typescript/18094.md @@ -1,37 +1,21 @@ -#### Remove extra indention in class type parameters (#18094 by @fisker) +#### Fix the inconsistent printing between class and interface (#18094, #18091 by @fisker) - +##### The extra indentation for type parameters in class has been removed ```tsx // Input interface MarkDef< M extends string | Mark = Mark, - ES extends ExprRef | SignalRef = ExprRef | SignalRef -> extends - A, - B {} + ES extends ExprRef | SignalRef = ExprRef | SignalRef, +> + extends A, B {} declare class MarkDef< M extends string | Mark = Mark, - ES extends ExprRef | SignalRef = ExprRef | SignalRef -> implements - A, - B {} + ES extends ExprRef | SignalRef = ExprRef | SignalRef, +> + implements A, B {} // Prettier stable interface MarkDef< @@ -50,8 +34,8 @@ declare class MarkDef< interface MarkDef< M extends string | Mark = Mark, ES extends ExprRef | SignalRef = ExprRef | SignalRef, -> extends A, - B {} +> + extends A, B {} declare class MarkDef< M extends string | Mark = Mark, @@ -60,4 +44,88 @@ declare class MarkDef< implements A, B {} ``` -_This change also affects Flow syntax_ +##### Align interface heritages print with class + + +```tsx +// Input +export interface AreaConfig + extends MarkConfig, PointOverlayMixins, LineOverlayMixins {} + +export class AreaConfig + implements MarkConfig, PointOverlayMixins, LineOverlayMixins {} + +// Prettier stable +export interface AreaConfig + extends MarkConfig, + PointOverlayMixins, + LineOverlayMixins {} + +export class AreaConfig + implements MarkConfig, PointOverlayMixins, LineOverlayMixins {} + +// Prettier main +export interface AreaConfig + extends MarkConfig, PointOverlayMixins, LineOverlayMixins {} + +export class AreaConfig + implements MarkConfig, PointOverlayMixins, LineOverlayMixins {} +``` + +##### Inconsistent opening brace print logic of class and interface body + +In Prettier v2.3, to improve visual separation between class head and body, [we start to print `{` of class body on a new line when the class has multiple heritages](https://prettier.io/blog/2021/05/09/2.3.0.html#improve-visual-separation-between-header-and-body-in-classes-with-multiline-headers-10085-by-sosukesuzuki). + + +```tsx +// Prettier 2.2 +class loooooooooooooooooooong + extends looooooooooooooooooong + implements loooooooooooooooooooong { + property: string; +} + +// Prettier 2.3 +class loooooooooooooooooooong + extends looooooooooooooooooong + implements loooooooooooooooooooong +{ + property: string; +} +``` + +However, not everyone is happy with this change. + +Let us know what you think about applying this change to interfaces, please leave a comment on [this issue](https://github.com/prettier/prettier/issues/18115). + +If you have a better solution for this issue, we'll be happy to discuss it too. + +Unless a better solution comes up, we'll align the interface body print with the one for the class body in Prettier v4. + + +```tsx +// Input +declare class loooooooooooooooooooong + implements looooooooooooooooooong, loooooooooooooooooooong { + property: string; +} + +interface loooooooooooooooooooong + extends looooooooooooooooooong, loooooooooooooooooooong { + property: string; +} + +// Prettier main +declare class loooooooooooooooooooong + implements looooooooooooooooooong, loooooooooooooooooooong +{ + property: string; +} + +interface loooooooooooooooooooong + extends looooooooooooooooooong, loooooooooooooooooooong { // <-- This + property: string; +} +``` + +_These changes also affect Flow syntax_ diff --git a/changelog_unreleased/typescript/18109.md b/changelog_unreleased/typescript/18109.md index d89e78357..00d6b1e6f 100644 --- a/changelog_unreleased/typescript/18109.md +++ b/changelog_unreleased/typescript/18109.md @@ -31,4 +31,4 @@ type A = // comment | BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong; ``` -_This change applies to Flow syntax too_ +_This change also affect Flow syntax_ diff --git a/src/language-js/print/class.js b/src/language-js/print/class.js index defeab3c1..44c6d9e21 100644 --- a/src/language-js/print/class.js +++ b/src/language-js/print/class.js @@ -37,6 +37,8 @@ import { getTypeParametersGroupId } from "./type-parameters.js"; * @import {Doc} from "../../document/builders.js" */ +const getHeritageGroupId = createGroupIdMapper("heritageGroup"); + const isClassProperty = createTypeCheckFunction([ "ClassProperty", "PropertyDefinition", @@ -47,15 +49,32 @@ const isClassProperty = createTypeCheckFunction([ "TSAbstractAccessorProperty", ]); +const isInterface = createTypeCheckFunction([ + "TSInterfaceDeclaration", + "DeclareInterface", + "InterfaceDeclaration", + "InterfaceTypeAnnotation", +]); + /* - `ClassDeclaration` - `ClassExpression` - `DeclareClass`(flow) +- `DeclareInterface`(flow) +- `InterfaceDeclaration`(flow) +- `InterfaceTypeAnnotation`(flow) +- `TSInterfaceDeclaration`(TypeScript) */ function printClass(path, options, print) { const { node } = path; + const isPrintingInterface = isInterface(node); + /** @type {Doc[]} */ - const parts = [printDeclareToken(path), printAbstractToken(path), "class"]; + const parts = [ + printDeclareToken(path), + printAbstractToken(path), + isPrintingInterface ? "interface" : "class", + ]; // Keep old behaviour of extends in same line // If there is only on extends and there are not comments @@ -63,18 +82,20 @@ function printClass(path, options, print) { hasComment(node.id, CommentCheckFlags.Trailing) || hasComment(node.typeParameters, CommentCheckFlags.Trailing) || hasComment(node.superClass) || - isNonEmptyArray(node.extends) || // DeclareClass + isNonEmptyArray(node.extends) || isNonEmptyArray(node.mixins) || isNonEmptyArray(node.implements); const partsGroup = []; const extendsParts = []; - if (node.id) { - partsGroup.push(" ", print("id")); - } + if (node.type !== "InterfaceTypeAnnotation") { + if (node.id) { + partsGroup.push(" ", print("id")); + } - partsGroup.push(print("typeParameters")); + partsGroup.push(print("typeParameters")); + } if (node.superClass) { const printed = [ @@ -112,8 +133,15 @@ function printClass(path, options, print) { parts.push(...partsGroup, ...extendsParts); } - const classBody = node.body; - if (groupMode && isNonEmptyArray(classBody.body)) { + /* + To improve visual separation between class head and body https://github.com/prettier/prettier/issues/10018 + we introduced https://github.com/prettier/prettier/pull/10085 + However, users complaint. + We decide to defer to solve the inconsistency to a major release (V4) + Meanwhile, we are not going to put the `{` of interface body on a new line + https://github.com/prettier/prettier/issues/18115 + */ + if (!isPrintingInterface && groupMode && isNonEmptyClassBody(node.body)) { parts.push(ifBreak(hardline, " ", { groupId: heritageGroupId })); } else { parts.push(" "); @@ -124,10 +152,12 @@ function printClass(path, options, print) { return parts; } -const getHeritageGroupId = createGroupIdMapper("heritageGroup"); - -function printHardlineAfterHeritage(node) { - return ifBreak(hardline, "", { groupId: getHeritageGroupId(node) }); +function isNonEmptyClassBody(node) { + return node.type === "ObjectTypeAnnotation" + ? ["properties", "indexers", "callProperties", "internalSlots"].some( + (property) => isNonEmptyArray(node[property]), + ) + : isNonEmptyArray(node.body); } function hasMultipleHeritage(node) { @@ -386,10 +416,4 @@ function shouldPrintSemicolonAfterClassProperty(node, nextNode) { return false; } -export { - printClass, - printClassBody, - printClassMethod, - printClassProperty, - printHardlineAfterHeritage, -}; +export { printClass, printClassBody, printClassMethod, printClassProperty }; diff --git a/src/language-js/print/flow.js b/src/language-js/print/flow.js index 1da0d4536..be08f2466 100644 --- a/src/language-js/print/flow.js +++ b/src/language-js/print/flow.js @@ -25,7 +25,6 @@ import { printHook, printHookTypeAnnotation, } from "./hook.js"; -import { printInterface } from "./interface.js"; import { printBigInt } from "./literal.js"; import { printFlowMappedTypeProperty } from "./mapped-type.js"; import { printMatch, printMatchCase, printMatchPattern } from "./match.js"; @@ -79,8 +78,6 @@ function printFlow(path, options, print) { return printDeclareHook(path, options, print); case "HookTypeAnnotation": return printHookTypeAnnotation(path, options, print); - case "DeclareClass": - return printClass(path, options, print); case "DeclareFunction": return [ printDeclareToken(path), @@ -202,10 +199,11 @@ function printFlow(path, options, print) { ]; } + case "DeclareClass": case "DeclareInterface": case "InterfaceDeclaration": case "InterfaceTypeAnnotation": - return printInterface(path, options, print); + return printClass(path, options, print); case "ClassImplements": case "InterfaceExtends": return [print("id"), print("typeParameters")]; diff --git a/src/language-js/print/interface.js b/src/language-js/print/interface.js deleted file mode 100644 index 0e19cb3dc..000000000 --- a/src/language-js/print/interface.js +++ /dev/null @@ -1,68 +0,0 @@ -import { group, ifBreak, indent, join, line } from "../../document/builders.js"; -import isNonEmptyArray from "../../utils/is-non-empty-array.js"; -import { CommentCheckFlags, hasComment, identity } from "../utils/index.js"; -import { printDeclareToken } from "./misc.js"; -import { getTypeParametersGroupId } from "./type-parameters.js"; - -/** - * @import {Doc} from "../../document/builders.js" - */ - -/* -- `TSInterfaceDeclaration`(TypeScript) -- `DeclareInterface`(flow) -- `InterfaceDeclaration`(flow) -- `InterfaceTypeAnnotation`(flow) -*/ -function printInterface(path, options, print) { - const { node } = path; - /** @type {Doc[]} */ - const parts = [printDeclareToken(path), "interface"]; - - const partsGroup = []; - const extendsParts = []; - - if (node.type !== "InterfaceTypeAnnotation") { - partsGroup.push(" ", print("id"), print("typeParameters")); - } - - const shouldIndentOnlyHeritageClauses = - node.typeParameters && - !hasComment( - node.typeParameters, - CommentCheckFlags.Trailing | CommentCheckFlags.Line, - ); - - if (isNonEmptyArray(node.extends)) { - extendsParts.push( - shouldIndentOnlyHeritageClauses - ? ifBreak(" ", line, { - groupId: getTypeParametersGroupId(node.typeParameters), - }) - : line, - "extends ", - (node.extends.length === 1 ? identity : indent)( - join([",", line], path.map(print, "extends")), - ), - ); - } - - if ( - hasComment(node.id, CommentCheckFlags.Trailing) || - isNonEmptyArray(node.extends) - ) { - if (shouldIndentOnlyHeritageClauses) { - parts.push(group([...partsGroup, indent(extendsParts)])); - } else { - parts.push(group(indent([...partsGroup, ...extendsParts]))); - } - } else { - parts.push(...partsGroup, ...extendsParts); - } - - parts.push(" ", print("body")); - - return group(parts); -} - -export { printInterface }; diff --git a/src/language-js/print/object.js b/src/language-js/print/object.js index e0f38641f..dd49a4476 100644 --- a/src/language-js/print/object.js +++ b/src/language-js/print/object.js @@ -22,7 +22,6 @@ import { isObjectType, shouldPrintComma, } from "../utils/index.js"; -import { printHardlineAfterHeritage } from "./class.js"; import { shouldHugTheOnlyFunctionParameter } from "./function-parameters.js"; import { printOptionalToken } from "./misc.js"; import { printTypeAnnotationProperty } from "./type-annotation.js"; @@ -217,9 +216,6 @@ function printObject(path, options, print) { } else { const spacing = options.bracketSpacing ? line : softline; content = [ - isFlowInterfaceLikeBody && isNonEmptyArray(node.properties) - ? printHardlineAfterHeritage(parent) - : "", leftBrace, indent([spacing, ...props]), ifBreak( diff --git a/src/language-js/print/typescript.js b/src/language-js/print/typescript.js index 01010ff43..86697c074 100644 --- a/src/language-js/print/typescript.js +++ b/src/language-js/print/typescript.js @@ -17,7 +17,7 @@ import { printArray } from "./array.js"; import { printBlock } from "./block.js"; import { printCallExpression } from "./call-expression.js"; import { printBinaryCastExpression } from "./cast-expression.js"; -import { printClassMethod, printClassProperty } from "./class.js"; +import { printClass, printClassMethod, printClassProperty } from "./class.js"; import { printEnumBody, printEnumDeclaration, @@ -28,7 +28,6 @@ import { printFunctionParameters, shouldGroupFunctionParameters, } from "./function-parameters.js"; -import { printInterface } from "./interface.js"; import { printTypeScriptMappedType } from "./mapped-type.js"; import { printDeclareToken, @@ -135,7 +134,7 @@ function printTypescript(path, options, print) { case "TSOptionalType": return [print("typeAnnotation"), "?"]; case "TSInterfaceDeclaration": - return printInterface(path, options, print); + return printClass(path, options, print); case "TSTypeParameterDeclaration": case "TSTypeParameterInstantiation": return printTypeParameters(path, options, print, "params"); diff --git a/src/language-js/utils/index.js b/src/language-js/utils/index.js index bbd1bc05b..25f621875 100644 --- a/src/language-js/utils/index.js +++ b/src/language-js/utils/index.js @@ -657,10 +657,6 @@ function isSimpleCallArgument(node, depth = 2) { return false; } -function identity(x) { - return x; -} - /** * @param {any} options * @param {("es5" | "all")} [level] @@ -1099,7 +1095,6 @@ export { hasNode, hasNodeIgnoreComment, hasRestParameter, - identity, isArrayExpression, isBinaryCastExpression, isBinaryish, diff --git a/tests/format/flow/interface-types/break/__snapshots__/format.test.js.snap b/tests/format/flow/interface-types/break/__snapshots__/format.test.js.snap index 774e3231c..a2684eaa7 100644 --- a/tests/format/flow/interface-types/break/__snapshots__/format.test.js.snap +++ b/tests/format/flow/interface-types/break/__snapshots__/format.test.js.snap @@ -102,7 +102,8 @@ declare interface ExtendsLarge } declare interface ExtendsMany - extends Interface1, + extends + Interface1, Interface2, Interface3, Interface4, @@ -123,7 +124,8 @@ interface ExtendsLarge } interface ExtendsMany - extends Interface1, + extends + Interface1, Interface2, Interface3, Interface4, @@ -144,20 +146,22 @@ interface ExtendsLarge } interface ExtendsMany - extends ASingleGenericInterface< - Interface1, - Interface2, - Interface3, - Interface4, - Interface5, - Interface6, - Interface7, - > { + extends + ASingleGenericInterface< + Interface1, + Interface2, + Interface3, + Interface4, + Interface5, + Interface6, + Interface7, + > { x: string; } interface ExtendsManyWithGenerics - extends InterfaceOne, + extends + InterfaceOne, InterfaceTwo, ASingleGenericInterface< Interface1, @@ -173,10 +177,11 @@ interface ExtendsManyWithGenerics } export interface ExtendsLongOneWithGenerics - extends Bar< - SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, - ToBreakLineToBreakLineToBreakLine, - > {} + extends + Bar< + SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, + ToBreakLineToBreakLineToBreakLine, + > {} ================================================================================ `; @@ -283,7 +288,8 @@ declare interface ExtendsLarge } declare interface ExtendsMany - extends Interface1, + extends + Interface1, Interface2, Interface3, Interface4, @@ -304,7 +310,8 @@ interface ExtendsLarge } interface ExtendsMany - extends Interface1, + extends + Interface1, Interface2, Interface3, Interface4, @@ -325,20 +332,22 @@ interface ExtendsLarge } interface ExtendsMany - extends ASingleGenericInterface< - Interface1, - Interface2, - Interface3, - Interface4, - Interface5, - Interface6, - Interface7, - > { + extends + ASingleGenericInterface< + Interface1, + Interface2, + Interface3, + Interface4, + Interface5, + Interface6, + Interface7, + > { x: string; } interface ExtendsManyWithGenerics - extends InterfaceOne, + extends + InterfaceOne, InterfaceTwo, ASingleGenericInterface< Interface1, @@ -354,10 +363,11 @@ interface ExtendsManyWithGenerics } export interface ExtendsLongOneWithGenerics - extends Bar< - SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, - ToBreakLineToBreakLineToBreakLine, - > {} + extends + Bar< + SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, + ToBreakLineToBreakLineToBreakLine, + > {} ================================================================================ `; @@ -464,7 +474,8 @@ declare interface ExtendsLarge } declare interface ExtendsMany - extends Interface1, + extends + Interface1, Interface2, Interface3, Interface4, @@ -485,7 +496,8 @@ interface ExtendsLarge } interface ExtendsMany - extends Interface1, + extends + Interface1, Interface2, Interface3, Interface4, @@ -506,20 +518,22 @@ interface ExtendsLarge } interface ExtendsMany - extends ASingleGenericInterface< - Interface1, - Interface2, - Interface3, - Interface4, - Interface5, - Interface6, - Interface7 - > { + extends + ASingleGenericInterface< + Interface1, + Interface2, + Interface3, + Interface4, + Interface5, + Interface6, + Interface7 + > { x: string; } interface ExtendsManyWithGenerics - extends InterfaceOne, + extends + InterfaceOne, InterfaceTwo, ASingleGenericInterface< Interface1, @@ -535,10 +549,11 @@ interface ExtendsManyWithGenerics } export interface ExtendsLongOneWithGenerics - extends Bar< - SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, - ToBreakLineToBreakLineToBreakLine - > {} + extends + Bar< + SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, + ToBreakLineToBreakLineToBreakLine + > {} ================================================================================ `; diff --git a/tests/format/typescript/class-and-interface/long-type-parameters/__snapshots__/format.test.js.snap b/tests/format/typescript/class-and-interface/long-type-parameters/__snapshots__/format.test.js.snap index 91bfd5407..df3910926 100644 --- a/tests/format/typescript/class-and-interface/long-type-parameters/__snapshots__/format.test.js.snap +++ b/tests/format/typescript/class-and-interface/long-type-parameters/__snapshots__/format.test.js.snap @@ -26,9 +26,8 @@ declare class MarkDef< export interface MarkDef< M extends string | Mark = Mark, ES extends ExprRef | SignalRef = ExprRef | SignalRef, -> extends A, - B, - C {} +> + extends A, B, C {} declare class MarkDef< M extends string | Mark = Mark, diff --git a/tests/format/typescript/interface/__snapshots__/format.test.js.snap b/tests/format/typescript/interface/__snapshots__/format.test.js.snap index ceb84e875..37bc153f6 100644 --- a/tests/format/typescript/interface/__snapshots__/format.test.js.snap +++ b/tests/format/typescript/interface/__snapshots__/format.test.js.snap @@ -81,35 +81,35 @@ interface Foo< =====================================output===================================== interface ReallyReallyLongName< - TypeArgumentNumberOne, - TypeArgumentNumberTwo, - TypeArgumentNumberThree, - > // 1 + TypeArgumentNumberOne, + TypeArgumentNumberTwo, + TypeArgumentNumberThree, +> // 1 extends BaseInterface {} interface ReallyReallyLongName2< - TypeArgumentNumberOne, - TypeArgumentNumberTwo, - TypeArgumentNumberThree, - > // 1 - // 2 + TypeArgumentNumberOne, + TypeArgumentNumberTwo, + TypeArgumentNumberThree, +> // 1 +// 2 extends BaseInterface {} interface ReallyReallyLongName3< - TypeArgumentNumberOne, - TypeArgumentNumberTwo, - TypeArgumentNumberThree, - > // 1 - // 2 + TypeArgumentNumberOne, + TypeArgumentNumberTwo, + TypeArgumentNumberThree, +> // 1 +// 2 extends BaseInterface { // 3 } interface Foo< - FOOOOOOOOOOOOOOOOOOOOOOOOOO, - FOOOOOOOOOOOOOOOOOOOOOOOOOO, - FOOOOOOOOOOOOOOOOOOOOOOOOOO, - > // comments + FOOOOOOOOOOOOOOOOOOOOOOOOOO, + FOOOOOOOOOOOOOOOOOOOOOOOOOO, + FOOOOOOOOOOOOOOOOOOOOOOOOOO, +> // comments extends Foo {} ================================================================================ @@ -154,35 +154,35 @@ interface Foo< =====================================output===================================== interface ReallyReallyLongName< - TypeArgumentNumberOne, - TypeArgumentNumberTwo, - TypeArgumentNumberThree, - > // 1 + TypeArgumentNumberOne, + TypeArgumentNumberTwo, + TypeArgumentNumberThree, +> // 1 extends BaseInterface {} interface ReallyReallyLongName2< - TypeArgumentNumberOne, - TypeArgumentNumberTwo, - TypeArgumentNumberThree, - > // 1 - // 2 + TypeArgumentNumberOne, + TypeArgumentNumberTwo, + TypeArgumentNumberThree, +> // 1 +// 2 extends BaseInterface {} interface ReallyReallyLongName3< - TypeArgumentNumberOne, - TypeArgumentNumberTwo, - TypeArgumentNumberThree, - > // 1 - // 2 + TypeArgumentNumberOne, + TypeArgumentNumberTwo, + TypeArgumentNumberThree, +> // 1 +// 2 extends BaseInterface { // 3 } interface Foo< - FOOOOOOOOOOOOOOOOOOOOOOOOOO, - FOOOOOOOOOOOOOOOOOOOOOOOOOO, - FOOOOOOOOOOOOOOOOOOOOOOOOOO, - > // comments + FOOOOOOOOOOOOOOOOOOOOOOOOOO, + FOOOOOOOOOOOOOOOOOOOOOOOOOO, + FOOOOOOOOOOOOOOOOOOOOOOOOOO, +> // comments extends Foo {} ================================================================================ @@ -732,19 +732,20 @@ export interface ThirdVeryLongAndBoringInterfaceName } export interface ThirdVeryLongAndBoringInterfaceName - extends ALongAndBoringInterfaceName, - AnotherLongAndBoringInterfaceName { + extends ALongAndBoringInterfaceName, AnotherLongAndBoringInterfaceName { c: string } export interface ThirdVeryLongAndBoringInterfaceName - extends AVeryLongAndBoringInterfaceName, + extends + AVeryLongAndBoringInterfaceName, AnotherVeryLongAndBoringInterfaceName { c: string } export interface ThirdVeryLongAndBoringInterfaceName - extends A_AVeryLongAndBoringInterfaceName, + extends + A_AVeryLongAndBoringInterfaceName, B_AVeryLongAndBoringInterfaceName, C_AVeryLongAndBoringInterfaceName { c: string @@ -790,19 +791,20 @@ export interface ThirdVeryLongAndBoringInterfaceName } export interface ThirdVeryLongAndBoringInterfaceName - extends ALongAndBoringInterfaceName, - AnotherLongAndBoringInterfaceName { + extends ALongAndBoringInterfaceName, AnotherLongAndBoringInterfaceName { c: string; } export interface ThirdVeryLongAndBoringInterfaceName - extends AVeryLongAndBoringInterfaceName, + extends + AVeryLongAndBoringInterfaceName, AnotherVeryLongAndBoringInterfaceName { c: string; } export interface ThirdVeryLongAndBoringInterfaceName - extends A_AVeryLongAndBoringInterfaceName, + extends + A_AVeryLongAndBoringInterfaceName, B_AVeryLongAndBoringInterfaceName, C_AVeryLongAndBoringInterfaceName { c: string; diff --git a/tests/format/typescript/interface/long-type-parameters/__snapshots__/format.test.js.snap b/tests/format/typescript/interface/long-type-parameters/__snapshots__/format.test.js.snap index f31826250..fb8b7e247 100644 --- a/tests/format/typescript/interface/long-type-parameters/__snapshots__/format.test.js.snap +++ b/tests/format/typescript/interface/long-type-parameters/__snapshots__/format.test.js.snap @@ -26,7 +26,9 @@ export interface MarkDef< export interface MarkDef< M extends string | Mark = Mark, ES extends ExprRef | SignalRef = ExprRef | SignalRef, -> extends GenericMarkDef, +> + extends + GenericMarkDef, Omit< MarkConfig & AreaConfig & @@ -64,7 +66,8 @@ export interface MarkDef< =====================================output===================================== // https://github.com/vega/vega-lite/blob/ae13aff7b480cf9c994031eca08a6b1720e01ab3/src/mark.ts#L602 export interface MarkDef - extends GenericMarkDef, + extends + GenericMarkDef, Omit< MarkConfig & AreaConfig & diff --git a/tests/format/typescript/interface2/break/__snapshots__/format.test.js.snap b/tests/format/typescript/interface2/break/__snapshots__/format.test.js.snap index 418dde16a..ce021fa58 100644 --- a/tests/format/typescript/interface2/break/__snapshots__/format.test.js.snap +++ b/tests/format/typescript/interface2/break/__snapshots__/format.test.js.snap @@ -102,7 +102,8 @@ declare interface ExtendsLarge } declare interface ExtendsMany - extends Interface1, + extends + Interface1, Interface2, Interface3, Interface4, @@ -123,7 +124,8 @@ interface ExtendsLarge } interface ExtendsMany - extends Interface1, + extends + Interface1, Interface2, Interface3, Interface4, @@ -144,20 +146,22 @@ interface ExtendsLarge } interface ExtendsMany - extends ASingleGenericInterface< - Interface1, - Interface2, - Interface3, - Interface4, - Interface5, - Interface6, - Interface7 - > { + extends + ASingleGenericInterface< + Interface1, + Interface2, + Interface3, + Interface4, + Interface5, + Interface6, + Interface7 + > { x: string; } interface ExtendsManyWithGenerics - extends InterfaceOne, + extends + InterfaceOne, InterfaceTwo, ASingleGenericInterface< Interface1, @@ -173,10 +177,11 @@ interface ExtendsManyWithGenerics } export interface ExtendsLongOneWithGenerics - extends Bar< - SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, - ToBreakLineToBreakLineToBreakLine - > {} + extends + Bar< + SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, + ToBreakLineToBreakLineToBreakLine + > {} ================================================================================ `; @@ -283,7 +288,8 @@ declare interface ExtendsLarge } declare interface ExtendsMany - extends Interface1, + extends + Interface1, Interface2, Interface3, Interface4, @@ -304,7 +310,8 @@ interface ExtendsLarge } interface ExtendsMany - extends Interface1, + extends + Interface1, Interface2, Interface3, Interface4, @@ -325,20 +332,22 @@ interface ExtendsLarge } interface ExtendsMany - extends ASingleGenericInterface< - Interface1, - Interface2, - Interface3, - Interface4, - Interface5, - Interface6, - Interface7 - > { + extends + ASingleGenericInterface< + Interface1, + Interface2, + Interface3, + Interface4, + Interface5, + Interface6, + Interface7 + > { x: string; } interface ExtendsManyWithGenerics - extends InterfaceOne, + extends + InterfaceOne, InterfaceTwo, ASingleGenericInterface< Interface1, @@ -354,10 +363,11 @@ interface ExtendsManyWithGenerics } export interface ExtendsLongOneWithGenerics - extends Bar< - SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, - ToBreakLineToBreakLineToBreakLine - > {} + extends + Bar< + SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, + ToBreakLineToBreakLineToBreakLine + > {} ================================================================================ `; @@ -464,7 +474,8 @@ declare interface ExtendsLarge } declare interface ExtendsMany - extends Interface1, + extends + Interface1, Interface2, Interface3, Interface4, @@ -485,7 +496,8 @@ interface ExtendsLarge } interface ExtendsMany - extends Interface1, + extends + Interface1, Interface2, Interface3, Interface4, @@ -506,20 +518,22 @@ interface ExtendsLarge } interface ExtendsMany - extends ASingleGenericInterface< - Interface1, - Interface2, - Interface3, - Interface4, - Interface5, - Interface6, - Interface7 - > { + extends + ASingleGenericInterface< + Interface1, + Interface2, + Interface3, + Interface4, + Interface5, + Interface6, + Interface7 + > { x: string; } interface ExtendsManyWithGenerics - extends InterfaceOne, + extends + InterfaceOne, InterfaceTwo, ASingleGenericInterface< Interface1, @@ -535,10 +549,11 @@ interface ExtendsManyWithGenerics } export interface ExtendsLongOneWithGenerics - extends Bar< - SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, - ToBreakLineToBreakLineToBreakLine - > {} + extends + Bar< + SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, + ToBreakLineToBreakLineToBreakLine + > {} ================================================================================ `;