Fix flow extends not breaking out into new lines (#5244)

master
Aquib Master 2018-10-26 03:49:53 +13:00 committed by Jed Fox
parent 2cc32da5af
commit 1234ceb1d6
3 changed files with 178 additions and 1 deletions

View File

@ -2651,7 +2651,11 @@ function printPathNoParens(path, options, print, args) {
parts.push(
group(
indent(
concat([line, "extends ", join(", ", path.map(print, "extends"))])
concat([
line,
"extends ",
indent(join(concat([",", line]), path.map(print, "extends")))
])
)
)
);

View File

@ -19,6 +19,52 @@ export class Environment2 extends GenericEnvironment<
> {
m() {};
};
// Declare Interface Break
declare interface ExtendsOne extends ASingleInterface {
x: string;
}
declare interface ExtendsLarge extends ASingleInterfaceWithAReallyReallyReallyReallyLongName {
x: string;
}
declare interface ExtendsMany extends Interface1, Interface2, Interface3, Interface4, Interface5, Interface6, Interface7 {
x: string;
}
// Interface declaration break
interface ExtendsOne extends ASingleInterface {
x: string;
}
interface ExtendsLarge extends ASingleInterfaceWithAReallyReallyReallyReallyLongName {
x: string;
}
interface ExtendsMany extends Interface1, Interface2, Interface3, Interface4, Interface5, Interface6, Interface7 {
s: string;
}
// Generic Types
interface ExtendsOne extends ASingleInterface<string> {
x: string;
}
interface ExtendsLarge extends ASingleInterfaceWithAReallyReallyReallyReallyLongName<string> {
x: string;
}
interface ExtendsMany
extends ASingleGenericInterface<Interface1, Interface2, Interface3, Interface4, Interface5, Interface6, Interface7> {
x: string;
}
interface ExtendsManyWithGenerics
extends InterfaceOne, InterfaceTwo, ASingleGenericInterface<Interface1, Interface2, Interface3, Interface4, Interface5, Interface6, Interface7>, InterfaceThree {
x: string;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export interface Environment1
extends GenericEnvironment<SomeType, AnotherType, YetAnotherType> {
@ -36,6 +82,87 @@ export class Environment2 extends GenericEnvironment<
m() {}
}
// Declare Interface Break
declare interface ExtendsOne extends ASingleInterface {
x: string;
}
declare interface ExtendsLarge
extends ASingleInterfaceWithAReallyReallyReallyReallyLongName {
x: string;
}
declare interface ExtendsMany
extends Interface1,
Interface2,
Interface3,
Interface4,
Interface5,
Interface6,
Interface7 {
x: string;
}
// Interface declaration break
interface ExtendsOne extends ASingleInterface {
x: string;
}
interface ExtendsLarge
extends ASingleInterfaceWithAReallyReallyReallyReallyLongName {
x: string;
}
interface ExtendsMany
extends Interface1,
Interface2,
Interface3,
Interface4,
Interface5,
Interface6,
Interface7 {
s: string;
}
// Generic Types
interface ExtendsOne extends ASingleInterface<string> {
x: string;
}
interface ExtendsLarge
extends ASingleInterfaceWithAReallyReallyReallyReallyLongName<string> {
x: string;
}
interface ExtendsMany
extends ASingleGenericInterface<
Interface1,
Interface2,
Interface3,
Interface4,
Interface5,
Interface6,
Interface7
> {
x: string;
}
interface ExtendsManyWithGenerics
extends InterfaceOne,
InterfaceTwo,
ASingleGenericInterface<
Interface1,
Interface2,
Interface3,
Interface4,
Interface5,
Interface6,
Interface7
>,
InterfaceThree {
x: string;
}
`;
exports[`module.js - flow-verify 1`] = `

View File

@ -16,3 +16,49 @@ export class Environment2 extends GenericEnvironment<
> {
m() {};
};
// Declare Interface Break
declare interface ExtendsOne extends ASingleInterface {
x: string;
}
declare interface ExtendsLarge extends ASingleInterfaceWithAReallyReallyReallyReallyLongName {
x: string;
}
declare interface ExtendsMany extends Interface1, Interface2, Interface3, Interface4, Interface5, Interface6, Interface7 {
x: string;
}
// Interface declaration break
interface ExtendsOne extends ASingleInterface {
x: string;
}
interface ExtendsLarge extends ASingleInterfaceWithAReallyReallyReallyReallyLongName {
x: string;
}
interface ExtendsMany extends Interface1, Interface2, Interface3, Interface4, Interface5, Interface6, Interface7 {
s: string;
}
// Generic Types
interface ExtendsOne extends ASingleInterface<string> {
x: string;
}
interface ExtendsLarge extends ASingleInterfaceWithAReallyReallyReallyReallyLongName<string> {
x: string;
}
interface ExtendsMany
extends ASingleGenericInterface<Interface1, Interface2, Interface3, Interface4, Interface5, Interface6, Interface7> {
x: string;
}
interface ExtendsManyWithGenerics
extends InterfaceOne, InterfaceTwo, ASingleGenericInterface<Interface1, Interface2, Interface3, Interface4, Interface5, Interface6, Interface7>, InterfaceThree {
x: string;
}