Replace printInterface with printClass (#18091)
This commit is contained in:
1 parent
a94d3cf453
commit
7de88d638b
13 files changed
+322
-276
No files matched your search
@@ -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)
|
||||
|
||||
<!--
|
||||
We plan to fix the inconsistent printing between class and interface, I(fisker) plan to put all changes together.
|
||||
|
||||
This addresses the first part of #18093.
|
||||
|
||||
We'll change this part to
|
||||
|
||||
```
|
||||
The extra indention for type parameters in class has been removed
|
||||
```
|
||||
|
||||
when we add more changes.
|
||||
|
||||
TODO: Update the output for `Prettier main` in #18091
|
||||
-->
|
||||
##### The extra indentation for type parameters in class has been removed
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```tsx
|
||||
// Input
|
||||
export interface AreaConfig<ES extends ExprRef | SignalRef>
|
||||
extends MarkConfig<ES>, PointOverlayMixins<ES>, LineOverlayMixins<ES> {}
|
||||
|
||||
export class AreaConfig<ES extends ExprRef | SignalRef>
|
||||
implements MarkConfig<ES>, PointOverlayMixins<ES>, LineOverlayMixins<ES> {}
|
||||
|
||||
// Prettier stable
|
||||
export interface AreaConfig<ES extends ExprRef | SignalRef>
|
||||
extends MarkConfig<ES>,
|
||||
PointOverlayMixins<ES>,
|
||||
LineOverlayMixins<ES> {}
|
||||
|
||||
export class AreaConfig<ES extends ExprRef | SignalRef>
|
||||
implements MarkConfig<ES>, PointOverlayMixins<ES>, LineOverlayMixins<ES> {}
|
||||
|
||||
// Prettier main
|
||||
export interface AreaConfig<ES extends ExprRef | SignalRef>
|
||||
extends MarkConfig<ES>, PointOverlayMixins<ES>, LineOverlayMixins<ES> {}
|
||||
|
||||
export class AreaConfig<ES extends ExprRef | SignalRef>
|
||||
implements MarkConfig<ES>, PointOverlayMixins<ES>, LineOverlayMixins<ES> {}
|
||||
```
|
||||
|
||||
##### 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).
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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_
|
||||
@@ -31,4 +31,4 @@ type A = // comment
|
||||
| BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
|
||||
```
|
||||
|
||||
_This change applies to Flow syntax too_
|
||||
_This change also affect Flow syntax_
|
||||
@@ -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 };
|
||||
@@ -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")];
|
||||
|
||||
@@ -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 };
|
||||
@@ -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(
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
> {}
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
+2
-3
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
+5
-2
@@ -26,7 +26,9 @@ export interface MarkDef<
|
||||
export interface MarkDef<
|
||||
M extends string | Mark = Mark,
|
||||
ES extends ExprRef | SignalRef = ExprRef | SignalRef,
|
||||
> extends GenericMarkDef<M>,
|
||||
>
|
||||
extends
|
||||
GenericMarkDef<M>,
|
||||
Omit<
|
||||
MarkConfig<ES> &
|
||||
AreaConfig<ES> &
|
||||
@@ -64,7 +66,8 @@ export interface MarkDef<
|
||||
=====================================output=====================================
|
||||
// https://github.com/vega/vega-lite/blob/ae13aff7b480cf9c994031eca08a6b1720e01ab3/src/mark.ts#L602
|
||||
export interface MarkDef<M extends string | Mark = Mark, ES extends ExprRef | SignalRef = ExprRef | SignalRef>
|
||||
extends GenericMarkDef<M>,
|
||||
extends
|
||||
GenericMarkDef<M>,
|
||||
Omit<
|
||||
MarkConfig<ES> &
|
||||
AreaConfig<ES> &
|
||||
|
||||
@@ -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
|
||||
> {}
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
Reference in new issue
Block a user