From 5e146cdabeb25fa1bfb94ac9b0a9efa497bfcf5b Mon Sep 17 00:00:00 2001 From: Moti Zilberman Date: Mon, 25 Sep 2017 12:45:40 +0100 Subject: [PATCH] Use semicolons in Flow interface-like bodies (#2593) Closes #2593. --- src/printer.js | 14 +- .../annot/__snapshots__/jsfmt.spec.js.snap | 4 +- .../flow/any/__snapshots__/jsfmt.spec.js.snap | 4 +- .../__snapshots__/jsfmt.spec.js.snap | 6 +- .../__snapshots__/jsfmt.spec.js.snap | 12 +- .../lib/__snapshots__/jsfmt.spec.js.snap | 22 +- .../lib/__snapshots__/jsfmt.spec.js.snap | 6 +- .../callable/__snapshots__/jsfmt.spec.js.snap | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 4 +- .../__snapshots__/jsfmt.spec.js.snap | 10 +- .../__snapshots__/jsfmt.spec.js.snap | 6 +- .../lib/__snapshots__/jsfmt.spec.js.snap | 4 +- .../lib/__snapshots__/jsfmt.spec.js.snap | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 6 +- .../__snapshots__/jsfmt.spec.js.snap | 28 +-- .../__snapshots__/jsfmt.spec.js.snap | 12 +- .../__snapshots__/jsfmt.spec.js.snap | 6 +- .../__snapshots__/jsfmt.spec.js.snap | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 2 +- .../optional/__snapshots__/jsfmt.spec.js.snap | 2 +- .../overload/__snapshots__/jsfmt.spec.js.snap | 12 +- .../lib/__snapshots__/jsfmt.spec.js.snap | 4 +- .../decls/__snapshots__/jsfmt.spec.js.snap | 16 +- .../__snapshots__/jsfmt.spec.js.snap | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 4 +- .../lib/__snapshots__/jsfmt.spec.js.snap | 4 +- .../__snapshots__/jsfmt.spec.js.snap | 14 +- .../__snapshots__/jsfmt.spec.js.snap | 16 +- .../taint/__snapshots__/jsfmt.spec.js.snap | 4 +- .../lib/__snapshots__/jsfmt.spec.js.snap | 6 +- .../traits/__snapshots__/jsfmt.spec.js.snap | 8 +- .../__snapshots__/jsfmt.spec.js.snap | 4 +- .../__snapshots__/jsfmt.spec.js.snap | 4 +- .../__snapshots__/jsfmt.spec.js.snap | 8 +- .../libs/__snapshots__/jsfmt.spec.js.snap | 22 +- .../union/__snapshots__/jsfmt.spec.js.snap | 6 +- .../__snapshots__/jsfmt.spec.js.snap | 66 ++--- .../lib/__snapshots__/jsfmt.spec.js.snap | 8 +- .../__snapshots__/jsfmt.spec.js.snap | 4 +- .../__snapshots__/jsfmt.spec.js.snap | 4 +- .../__snapshots__/jsfmt.spec.js.snap | 4 +- .../__snapshots__/jsfmt.spec.js.snap | 2 +- .../no-semi/__snapshots__/jsfmt.spec.js.snap | 234 ++++++++++++++++++ tests/no-semi/flow-interfaces.js | 38 +++ tests/rest/__snapshots__/jsfmt.spec.js.snap | 4 +- 45 files changed, 466 insertions(+), 186 deletions(-) create mode 100644 tests/no-semi/flow-interfaces.js diff --git a/src/printer.js b/src/printer.js index 1006d8f50..2a0dcc973 100644 --- a/src/printer.js +++ b/src/printer.js @@ -937,14 +937,22 @@ function genericPrintNoParens(path, options, print, args) { util.locStart(n), util.locEnd(n) )); - const separator = - n.type === "TSInterfaceBody" || n.type === "TSTypeLiteral" + const parent = path.getParentNode(0); + const isFlowInterfaceLikeBody = + isTypeAnnotation && + parent && + (parent.type === "InterfaceDeclaration" || + parent.type === "DeclareInterface" || + parent.type === "DeclareClass") && + path.getName() === "body"; + const separator = isFlowInterfaceLikeBody + ? ";" + : n.type === "TSInterfaceBody" || n.type === "TSTypeLiteral" ? ifBreak(semi, ";") : ","; const fields = []; const leftBrace = n.exact ? "{|" : "{"; const rightBrace = n.exact ? "|}" : "}"; - const parent = path.getParentNode(0); let propertiesField; diff --git a/tests/flow/annot/__snapshots__/jsfmt.spec.js.snap b/tests/flow/annot/__snapshots__/jsfmt.spec.js.snap index 1a76ac62c..82057b4e9 100644 --- a/tests/flow/annot/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/annot/__snapshots__/jsfmt.spec.js.snap @@ -268,8 +268,8 @@ type Merge = (a: T, b: T) => T; // hypothetical immutable map declare class Map { - (): Map, - insertWith(fn: Merge, k: K, v: V): Map + (): Map; + insertWith(fn: Merge, k: K, v: V): Map; } declare function foldr(fn: (a: A, b: B) => B, b: B, as: A[]): B; diff --git a/tests/flow/any/__snapshots__/jsfmt.spec.js.snap b/tests/flow/any/__snapshots__/jsfmt.spec.js.snap index 935c1b6c4..6bd66f50a 100644 --- a/tests/flow/any/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/any/__snapshots__/jsfmt.spec.js.snap @@ -183,8 +183,8 @@ function bar2(x: mixed) { // @flow declare class C { - bar(n1: number, n2: number): number, - bar(s1: string, s2: string): string + bar(n1: number, n2: number): number; + bar(s1: string, s2: string): string; } function foo(c: C, x: any): string { diff --git a/tests/flow/async_iteration/__snapshots__/jsfmt.spec.js.snap b/tests/flow/async_iteration/__snapshots__/jsfmt.spec.js.snap index 6874169a4..052fd467c 100644 --- a/tests/flow/async_iteration/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/async_iteration/__snapshots__/jsfmt.spec.js.snap @@ -85,9 +85,9 @@ async function f() { } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ declare interface File { - readLine(): Promise, - close(): void, - EOF: boolean + readLine(): Promise; + close(): void; + EOF: boolean; } declare function fileOpen(path: string): Promise; diff --git a/tests/flow/call_caching1/__snapshots__/jsfmt.spec.js.snap b/tests/flow/call_caching1/__snapshots__/jsfmt.spec.js.snap index 68ed1fcf9..61258f1dd 100644 --- a/tests/flow/call_caching1/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/call_caching1/__snapshots__/jsfmt.spec.js.snap @@ -48,7 +48,7 @@ foo( /* @flow */ declare class Bar { - update(updater: (value: this) => Bar): Bar + update(updater: (value: this) => Bar): Bar; } declare function foo( @@ -84,14 +84,14 @@ outer.set(ImmBox(inner)); // @flow declare class ImmBox { - static (x: any): ImmBox, - static (x: any): any + static (x: any): ImmBox; + static (x: any): any; } declare class Box { - constructor(x: T): void, - set(value: T): void, - get(): T + constructor(x: T): void; + set(value: T): void; + get(): T; } const outer = new Box(); diff --git a/tests/flow/call_caching1/lib/__snapshots__/jsfmt.spec.js.snap b/tests/flow/call_caching1/lib/__snapshots__/jsfmt.spec.js.snap index c77b512a1..8558261e8 100644 --- a/tests/flow/call_caching1/lib/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/call_caching1/lib/__snapshots__/jsfmt.spec.js.snap @@ -28,11 +28,11 @@ declare class Map { } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ declare class Array { - @@iterator(): Iterator, + @@iterator(): Iterator; map( callbackfn: (value: T, index: number, array: Array) => U, thisArg?: any - ): Array + ): Array; } type IteratorResult = @@ -40,20 +40,20 @@ type IteratorResult = | { done: false, value: Yield }; interface $Iterator<+Yield, +Return, -Next> { - @@iterator(): $Iterator, - next(value?: Next): IteratorResult + @@iterator(): $Iterator; + next(value?: Next): IteratorResult; } type Iterator<+T> = $Iterator; interface $Iterable<+Yield, +Return, -Next> { - @@iterator(): $Iterator + @@iterator(): $Iterator; } type Iterable<+T> = $Iterable; declare class Map { - @@iterator(): Iterator<[K, V]>, - constructor(iterable: ?Iterable<[K, V]>): void, - set(key: K, value: V): Map + @@iterator(): Iterator<[K, V]>; + constructor(iterable: ?Iterable<[K, V]>): void; + set(key: K, value: V): Map; } `; @@ -70,10 +70,10 @@ declare module "immutable" { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ declare module "immutable" { declare class Map { - static (iter: Iterator<[K, V]>): Map, - static (object: { +[k: K]: V }): Map, + static (iter: Iterator<[K, V]>): Map; + static (object: { +[k: K]: V }): Map; - set(key: K, value: V): this + set(key: K, value: V): this; } } diff --git a/tests/flow/call_caching2/lib/__snapshots__/jsfmt.spec.js.snap b/tests/flow/call_caching2/lib/__snapshots__/jsfmt.spec.js.snap index 117c95dd5..514483126 100644 --- a/tests/flow/call_caching2/lib/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/call_caching2/lib/__snapshots__/jsfmt.spec.js.snap @@ -16,9 +16,9 @@ declare class Iterable { declare class Array {} declare class Iterable { - static >(iter: Iter): Iter, - static (iter: Array): Iterable, - size: number + static >(iter: Iter): Iter; + static (iter: Array): Iterable; + size: number; } `; diff --git a/tests/flow/callable/__snapshots__/jsfmt.spec.js.snap b/tests/flow/callable/__snapshots__/jsfmt.spec.js.snap index 9c65e94df..afd299e70 100644 --- a/tests/flow/callable/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/callable/__snapshots__/jsfmt.spec.js.snap @@ -56,7 +56,7 @@ var dict: { [k: string]: any } = {}; dict(); // error, callable signature not found interface ICall { - (x: string): void + (x: string): void; } declare var icall: ICall; icall(0); // error, number ~> string diff --git a/tests/flow/constructor/__snapshots__/jsfmt.spec.js.snap b/tests/flow/constructor/__snapshots__/jsfmt.spec.js.snap index 716d35fd9..b18519f94 100644 --- a/tests/flow/constructor/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/constructor/__snapshots__/jsfmt.spec.js.snap @@ -35,14 +35,14 @@ class D { // the return type of a constructor overrides the type of the class declare class Bar {} declare class Foo { - constructor(iterable: U): Bar + constructor(iterable: U): Bar; } (new Foo("x"): Bar); // ok (new Foo(123): Bar); // error, number !~> string // also overrides when it returns a different specialization of the same class declare class Baz { - constructor(iterable: U): Baz + constructor(iterable: U): Baz; } (new Baz("x"): Baz); // ok (new Baz(123): Baz); // error, number !~> string diff --git a/tests/flow/constructor_annots/__snapshots__/jsfmt.spec.js.snap b/tests/flow/constructor_annots/__snapshots__/jsfmt.spec.js.snap index 11519b4e0..c58cdd8c5 100644 --- a/tests/flow/constructor_annots/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/constructor_annots/__snapshots__/jsfmt.spec.js.snap @@ -41,13 +41,13 @@ exports.Foo = Foo; // so you want to type Foo, by declaring it as a class interface IFooPrototype { - m: () => number + m: () => number; } interface IFoo extends IFooPrototype { - x: boolean, // error, should have declared x: number instead - static (): void, - static y: boolean, // error, should have declared static y: number instead - constructor(): void + x: boolean; // error, should have declared x: number instead + static (): void; + static y: boolean; // error, should have declared static y: number instead + constructor(): void; } exports.Foo2 = (Foo: Class); diff --git a/tests/flow/declare_class/__snapshots__/jsfmt.spec.js.snap b/tests/flow/declare_class/__snapshots__/jsfmt.spec.js.snap index 732907b33..79e444051 100644 --- a/tests/flow/declare_class/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/declare_class/__snapshots__/jsfmt.spec.js.snap @@ -18,10 +18,10 @@ declare class D extends C { } new D(123); // error, number ~> string ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ declare class C { - static x: number, - static foo(x: number): void, + static x: number; + static foo(x: number): void; - constructor(x: string): void + constructor(x: string): void; } C.x = ""; diff --git a/tests/flow/declare_class/lib/__snapshots__/jsfmt.spec.js.snap b/tests/flow/declare_class/lib/__snapshots__/jsfmt.spec.js.snap index 413f6df5b..3bc30172b 100644 --- a/tests/flow/declare_class/lib/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/declare_class/lib/__snapshots__/jsfmt.spec.js.snap @@ -12,13 +12,13 @@ declare class D extends _module.C { } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ declare class _C { - foo(): number + foo(): number; } declare var _module: { C: Class<_C> }; declare class D extends _module.C { - foo(): string + foo(): string; } `; diff --git a/tests/flow/declare_type/lib/__snapshots__/jsfmt.spec.js.snap b/tests/flow/declare_type/lib/__snapshots__/jsfmt.spec.js.snap index 99527ba42..deea4ac15 100644 --- a/tests/flow/declare_type/lib/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/declare_type/lib/__snapshots__/jsfmt.spec.js.snap @@ -46,7 +46,7 @@ declare module 'foo' { declare module "foo" { declare class A { - toz: number + toz: number; } declare var n: string; diff --git a/tests/flow/getters_and_setters_disabled/__snapshots__/jsfmt.spec.js.snap b/tests/flow/getters_and_setters_disabled/__snapshots__/jsfmt.spec.js.snap index a13a4e03c..d5425b26e 100644 --- a/tests/flow/getters_and_setters_disabled/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/getters_and_setters_disabled/__snapshots__/jsfmt.spec.js.snap @@ -58,9 +58,9 @@ type T = { }; declare class Foo { - get a(): number, - set b(x: number): void, - c: 10 + get a(): number; + set b(x: number): void; + c: 10; } class Bar { diff --git a/tests/flow/getters_and_setters_enabled/__snapshots__/jsfmt.spec.js.snap b/tests/flow/getters_and_setters_enabled/__snapshots__/jsfmt.spec.js.snap index ca123de3d..76447b88a 100644 --- a/tests/flow/getters_and_setters_enabled/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/getters_and_setters_enabled/__snapshots__/jsfmt.spec.js.snap @@ -197,28 +197,28 @@ foo.propOverriddenWithSetter = 123; // Error number ~> string var z: number = 123; declare class Foo { - get goodGetterWithAnnotation(): number, - set goodSetterWithAnnotation(x: number): void, + get goodGetterWithAnnotation(): number; + set goodSetterWithAnnotation(x: number): void; - get propWithMatchingGetterAndSetter(): number, - set propWithMatchingGetterAndSetter(x: number): void, + get propWithMatchingGetterAndSetter(): number; + set propWithMatchingGetterAndSetter(x: number): void; // The getter and setter need not have the same type - no error - get propWithSubtypingGetterAndSetter(): ?number, - set propWithSubtypingGetterAndSetter(x: number): void, + get propWithSubtypingGetterAndSetter(): ?number; + set propWithSubtypingGetterAndSetter(x: number): void; // The getter and setter need not have the same type - no error - set propWithSubtypingGetterAndSetterReordered(x: number): void, - get propWithSubtypingGetterAndSetterReordered(): ?number, + set propWithSubtypingGetterAndSetterReordered(x: number): void; + get propWithSubtypingGetterAndSetterReordered(): ?number; - get propWithMismatchingGetterAndSetter(): number, - set propWithMismatchingGetterAndSetter(x: string): void, // doesn't match getter (OK) + get propWithMismatchingGetterAndSetter(): number; + set propWithMismatchingGetterAndSetter(x: string): void; // doesn't match getter (OK) - propOverriddenWithGetter: number, - get propOverriddenWithGetter(): string, + propOverriddenWithGetter: number; + get propOverriddenWithGetter(): string; - propOverriddenWithSetter: number, - set propOverriddenWithSetter(x: string): void + propOverriddenWithSetter: number; + set propOverriddenWithSetter(x: string): void; } var foo = new Foo(); diff --git a/tests/flow/interface/__snapshots__/jsfmt.spec.js.snap b/tests/flow/interface/__snapshots__/jsfmt.spec.js.snap index 47a2beae3..dec814f23 100644 --- a/tests/flow/interface/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/interface/__snapshots__/jsfmt.spec.js.snap @@ -24,12 +24,12 @@ interface Bad { // @flow interface Ok { - [key: string]: string + [key: string]: string; } interface Bad { - [k1: string]: string, - [k2: number]: number // error: not supported (yet) + [k1: string]: string; + [k2: number]: number; // error: not supported (yet) } `; @@ -154,7 +154,7 @@ function foo(k: K) { (k.y: number); // error: y is string in I } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -interface I { x: number, y: string } +interface I { x: number; y: string } interface J { y: number } interface K extends I, J { x: string } // error: x is number in I function foo(k: K) { @@ -179,8 +179,8 @@ interface I { foo(x: number): void } (function foo(x: number) {}: I); // error, property \`foo\` not found function declare class C { - bar(i: I): void, - bar(f: (x: number) => void): void + bar(i: I): void; + bar(f: (x: number) => void): void; } new C().bar((x: string) => {}); // error, number ~/~> string diff --git a/tests/flow/lib_interfaces/declarations/__snapshots__/jsfmt.spec.js.snap b/tests/flow/lib_interfaces/declarations/__snapshots__/jsfmt.spec.js.snap index 2cb45d77c..8acf78d34 100644 --- a/tests/flow/lib_interfaces/declarations/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/lib_interfaces/declarations/__snapshots__/jsfmt.spec.js.snap @@ -10,11 +10,11 @@ interface CArrays extends C> { } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ interface C { - foo(): CArrays, - bar(): C + foo(): CArrays; + bar(): C; } interface CArrays extends C> { - bar(): C + bar(): C; } `; diff --git a/tests/flow/method_properties/__snapshots__/jsfmt.spec.js.snap b/tests/flow/method_properties/__snapshots__/jsfmt.spec.js.snap index 3f0b05575..f38b6f48e 100644 --- a/tests/flow/method_properties/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/method_properties/__snapshots__/jsfmt.spec.js.snap @@ -12,7 +12,7 @@ export {Foo}; // @flow declare class Foo { - bar?: () => string + bar?: () => string; } export { Foo }; diff --git a/tests/flow/object-method/__snapshots__/jsfmt.spec.js.snap b/tests/flow/object-method/__snapshots__/jsfmt.spec.js.snap index 0a2d4c774..9cb49845e 100644 --- a/tests/flow/object-method/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/object-method/__snapshots__/jsfmt.spec.js.snap @@ -20,7 +20,7 @@ import type { ObjectType } from './test'; function subtypeCheck(x: Interface): ObjectType { return x; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ interface Interface { - m(): void + m(): void; } import type { ObjectType } from "./test"; diff --git a/tests/flow/optional/__snapshots__/jsfmt.spec.js.snap b/tests/flow/optional/__snapshots__/jsfmt.spec.js.snap index 837c3fe39..d27a1e40d 100644 --- a/tests/flow/optional/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/optional/__snapshots__/jsfmt.spec.js.snap @@ -301,7 +301,7 @@ var i:I = new I(); var j:I = i.map(id => id); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ declare class I { - map(mapper: (value?: V) => M): I + map(mapper: (value?: V) => M): I; } var i: I = new I(); var j: I = i.map(id => id); diff --git a/tests/flow/overload/__snapshots__/jsfmt.spec.js.snap b/tests/flow/overload/__snapshots__/jsfmt.spec.js.snap index 1a3f492a3..0bfb6ed96 100644 --- a/tests/flow/overload/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/overload/__snapshots__/jsfmt.spec.js.snap @@ -65,11 +65,11 @@ var x3: string = "".replace(/pattern/, "..."); var x4: number = "".split(/pattern/)[0]; declare class C { - foo(x: number): number, - foo(x: string): string, + foo(x: number): number; + foo(x: string): string; - bar(x: { a: number }): number, - bar(x: { a: string }): string + bar(x: { a: number }): number; + bar(x: { a: string }): string; } var a = new C(); @@ -130,8 +130,8 @@ var foo = new Foo; (foo.bar('hmmm'): number); // error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ declare class Foo { - bar(x: "hmm"): number, - bar(x: string): string + bar(x: "hmm"): number; + bar(x: string): string; } var foo = new Foo(); (foo.bar("hmm"): number); // OK diff --git a/tests/flow/overload/lib/__snapshots__/jsfmt.spec.js.snap b/tests/flow/overload/lib/__snapshots__/jsfmt.spec.js.snap index 2e3a1eabf..dfb576d34 100644 --- a/tests/flow/overload/lib/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/overload/lib/__snapshots__/jsfmt.spec.js.snap @@ -7,8 +7,8 @@ declare class FakeUint8Array { } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ declare class FakeUint8Array { - set(index: number, value: number): void, - set(array: FakeUint8Array | Array, offset?: number): void + set(index: number, value: number): void; + set(array: FakeUint8Array | Array, offset?: number): void; } `; diff --git a/tests/flow/poly_overload/decls/__snapshots__/jsfmt.spec.js.snap b/tests/flow/poly_overload/decls/__snapshots__/jsfmt.spec.js.snap index d2292a224..aafe5d943 100644 --- a/tests/flow/poly_overload/decls/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/poly_overload/decls/__snapshots__/jsfmt.spec.js.snap @@ -23,16 +23,16 @@ interface Other { x: X } interface None {} interface Nada { y: Y } interface A { - foo(s: Some, e: None): A, - foo(s: Some, e: Nada): A, - foo(s: Other, e: None): A, - foo(s: Other, e: Nada): A + foo(s: Some, e: None): A; + foo(s: Some, e: Nada): A; + foo(s: Other, e: None): A; + foo(s: Other, e: Nada): A; } interface B extends A { - foo(s: Some, e: None): B, - foo(s: Some, e: Nada): B, - foo(s: Other, e: None): B, - foo(s: Other, e: Nada): B + foo(s: Some, e: None): B; + foo(s: Some, e: Nada): B; + foo(s: Other, e: None): B; + foo(s: Other, e: Nada): B; } `; diff --git a/tests/flow/refinements/__snapshots__/jsfmt.spec.js.snap b/tests/flow/refinements/__snapshots__/jsfmt.spec.js.snap index 220087428..fa559cddd 100644 --- a/tests/flow/refinements/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/refinements/__snapshots__/jsfmt.spec.js.snap @@ -432,7 +432,7 @@ function foo2(x: ?Class): string { } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ declare class Foo { - foo: string + foo: string; } function foo0(x: ?string): string { diff --git a/tests/flow/return_new/__snapshots__/jsfmt.spec.js.snap b/tests/flow/return_new/__snapshots__/jsfmt.spec.js.snap index 17ccfe07f..c50e44e1b 100644 --- a/tests/flow/return_new/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/return_new/__snapshots__/jsfmt.spec.js.snap @@ -73,8 +73,8 @@ d.x = ""; // error, string ~/~ number (but property x is found) module.exports = D; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ declare class D { - constructor(): { x: number }, // OK - y: any + constructor(): { x: number }; // OK + y: any; } var d = new D(); diff --git a/tests/flow/static_overload/lib/__snapshots__/jsfmt.spec.js.snap b/tests/flow/static_overload/lib/__snapshots__/jsfmt.spec.js.snap index 6e4861fb3..5b728bd17 100644 --- a/tests/flow/static_overload/lib/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/static_overload/lib/__snapshots__/jsfmt.spec.js.snap @@ -7,8 +7,8 @@ declare class StaticOverload { } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ declare class StaticOverload { - static foo(x: number): number, - static foo(x: string): string + static foo(x: number): number; + static foo(x: string): string; } `; diff --git a/tests/flow/structural_subtyping/__snapshots__/jsfmt.spec.js.snap b/tests/flow/structural_subtyping/__snapshots__/jsfmt.spec.js.snap index 26d0f3957..a9b671e6b 100644 --- a/tests/flow/structural_subtyping/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/structural_subtyping/__snapshots__/jsfmt.spec.js.snap @@ -19,7 +19,7 @@ var lengthTest4: IHasLength = true; // bool doesn't have length */ interface IHasLength { - length: number + length: number; } var lengthTest1: IHasLength = []; @@ -63,15 +63,15 @@ class ClassWithXString { } interface IHasXString { - x: string + x: string; } interface IHasXNumber { - x: number + x: number; } interface IHasYString { - y: string + y: string; } var testInstance1: IHasXString = new ClassWithXString(); @@ -107,7 +107,7 @@ function propTest6(y: {[key: string]: number}) { */ interface IHasXString { - x: string + x: string; } var propTest1: IHasXString = { x: "hello" }; @@ -142,8 +142,8 @@ var test3: HasOptional = { a: "hello", b: true }; // Error: boolean ~> number /* @flow */ interface HasOptional { - a: string, - b?: number + a: string; + b?: number; } var test1: HasOptional = { a: "hello" }; diff --git a/tests/flow/tagged-unions/__snapshots__/jsfmt.spec.js.snap b/tests/flow/tagged-unions/__snapshots__/jsfmt.spec.js.snap index 73b7dbb5c..bc4c7ca22 100644 --- a/tests/flow/tagged-unions/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/tagged-unions/__snapshots__/jsfmt.spec.js.snap @@ -98,16 +98,16 @@ if (data.kind === "user") { /* @flow */ declare interface IDataBase { - id: string, - name: string + id: string; + name: string; } declare interface IUserData extends IDataBase { - kind: "user" + kind: "user"; } declare interface ISystemData extends IDataBase { - kind: "system" + kind: "system"; } declare type IData = IUserData | ISystemData; @@ -155,16 +155,16 @@ if (data.kind === "system") { /* @flow */ declare interface IDataBase { - id: string, - name: string + id: string; + name: string; } declare interface IUserData extends IDataBase { - kind: "user" + kind: "user"; } declare interface ISystemData extends IDataBase { - kind: "system" + kind: "system"; } declare type IData = IUserData | ISystemData; diff --git a/tests/flow/taint/__snapshots__/jsfmt.spec.js.snap b/tests/flow/taint/__snapshots__/jsfmt.spec.js.snap index 8d777d004..48f12c591 100644 --- a/tests/flow/taint/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/taint/__snapshots__/jsfmt.spec.js.snap @@ -295,11 +295,11 @@ declare var fakeDocument: FakeDocument; declare var fakeLocation: FakeLocation; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ declare class FakeLocation { - assign(url: string): void + assign(url: string): void; } declare class FakeDocument { - location: FakeLocation + location: FakeLocation; } declare function doStuff(x: $Tainted): void; diff --git a/tests/flow/this_type/lib/__snapshots__/jsfmt.spec.js.snap b/tests/flow/this_type/lib/__snapshots__/jsfmt.spec.js.snap index 0fc1f6ee1..8f52bb248 100644 --- a/tests/flow/this_type/lib/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/this_type/lib/__snapshots__/jsfmt.spec.js.snap @@ -26,15 +26,15 @@ declare module "mini-immutable" { // is disabled for perf reasons, these will produce warnings. declare class LinkedList { - next(): this + next(): this; } declare class DoublyLinkedList extends LinkedList { - prev(): this + prev(): this; } declare module "mini-immutable" { declare class Map { - set(key: K, value: V): this // more precise than Map (see below) + set(key: K, value: V): this; // more precise than Map (see below) } declare class OrderedMap extends Map { // inherits set method returning OrderedMap instead of Map diff --git a/tests/flow/traits/__snapshots__/jsfmt.spec.js.snap b/tests/flow/traits/__snapshots__/jsfmt.spec.js.snap index 252f7dd15..1808e48e2 100644 --- a/tests/flow/traits/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/traits/__snapshots__/jsfmt.spec.js.snap @@ -28,16 +28,16 @@ declare class Foo extends Qux { } declare class Bar extends Baz { // KeyedIterable <: Iterable - y: T + y: T; } declare class Qux extends Baz { // Collection <: Iterable - y: T, - z: T + y: T; + z: T; } declare class Baz { // Iterable - x: T + x: T; } (new Foo().x: number); // error: Qux wins diff --git a/tests/flow/type_args_nonstrict/__snapshots__/jsfmt.spec.js.snap b/tests/flow/type_args_nonstrict/__snapshots__/jsfmt.spec.js.snap index 0ac9d2e0e..d30ab7967 100644 --- a/tests/flow/type_args_nonstrict/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/type_args_nonstrict/__snapshots__/jsfmt.spec.js.snap @@ -125,12 +125,12 @@ type MySubobject = { y: number } & MyObject; // no error // arity error in interface extends interface MyInterface { - x: T + x: T; } interface MySubinterface extends MyInterface { // no error - y: number + y: number; } // no arity error in extends of polymorphic class diff --git a/tests/flow/type_args_strict/__snapshots__/jsfmt.spec.js.snap b/tests/flow/type_args_strict/__snapshots__/jsfmt.spec.js.snap index 1cecc4649..9d2a5ff44 100644 --- a/tests/flow/type_args_strict/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/type_args_strict/__snapshots__/jsfmt.spec.js.snap @@ -123,12 +123,12 @@ type MySubobject = { y: number } & MyObject; // error, missing argument list // arity error in interface extends interface MyInterface { - x: T + x: T; } interface MySubinterface extends MyInterface { // error, missing argument list - y: number + y: number; } // *no* arity error in extends of polymorphic class diff --git a/tests/flow/type_param_scope/__snapshots__/jsfmt.spec.js.snap b/tests/flow/type_param_scope/__snapshots__/jsfmt.spec.js.snap index c9b6fabe7..478df03a2 100644 --- a/tests/flow/type_param_scope/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/type_param_scope/__snapshots__/jsfmt.spec.js.snap @@ -126,19 +126,19 @@ class B extends A { } interface C { - m(x: T): C + m(x: T): C; } interface D extends C { - m(x: T): D + m(x: T): D; } declare class E { - m(x: T): E + m(x: T): E; } declare class F extends E { - m(x: T): F + m(x: T): F; } // Bounds can refer to parent type params (until they are shadowed). diff --git a/tests/flow/type_param_variance2/libs/__snapshots__/jsfmt.spec.js.snap b/tests/flow/type_param_variance2/libs/__snapshots__/jsfmt.spec.js.snap index 46fec2ddf..d25ac0764 100644 --- a/tests/flow/type_param_variance2/libs/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/type_param_variance2/libs/__snapshots__/jsfmt.spec.js.snap @@ -64,33 +64,33 @@ declare class Promise { resolve: (result?: Promise | R) => void, reject: (error?: any) => void ) => void - ): void, + ): void; then( onFulfill?: ?(value: R) => Promise | ?U, onReject?: ?(error: any) => Promise | ?U - ): Promise, + ): Promise; done( onFulfill?: ?(value: R) => void, onReject?: ?(error: any) => void - ): void, + ): void; - catch(onReject?: (error: any) => ?Promise | U): Promise, + catch(onReject?: (error: any) => ?Promise | U): Promise; - static resolve(object?: Promise | T): Promise, - static reject(error?: any): Promise, + static resolve(object?: Promise | T): Promise; + static reject(error?: any): Promise; // Non-standard APIs - finally(onSettled?: ?(value: any) => Promise | U): Promise, + finally(onSettled?: ?(value: any) => Promise | U): Promise; - static cast(object?: T): Promise, - static all(promises: Array | T>): Promise>, - static race(promises: Array>): Promise, + static cast(object?: T): Promise; + static all(promises: Array | T>): Promise>; + static race(promises: Array>): Promise; static allObject( promisesByKey: T - ): Promise<{ [key: $Keys]: any }> + ): Promise<{ [key: $Keys]: any }>; } `; diff --git a/tests/flow/union/__snapshots__/jsfmt.spec.js.snap b/tests/flow/union/__snapshots__/jsfmt.spec.js.snap index 33c8fcf64..51587ffbe 100644 --- a/tests/flow/union/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/union/__snapshots__/jsfmt.spec.js.snap @@ -208,7 +208,7 @@ myclass.myfun(["1", "2", "3", "4", "5", "6", function (ar) {}]) myclass.myfun(["1", "2", "3", "4", "5", "6", "7", function (ar) {}]) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ declare class Myclass { - myfun(myarray: Array): any + myfun(myarray: Array): any; } declare var myclass: Myclass; @@ -538,8 +538,8 @@ function CD(b) { } declare class F { - foo(x: number): void, - foo(x: string): void + foo(x: number): void; + foo(x: string): void; } function corge(b) { var x = b ? "" : 0; diff --git a/tests/flow/union_new/__snapshots__/jsfmt.spec.js.snap b/tests/flow/union_new/__snapshots__/jsfmt.spec.js.snap index 5904aee40..4176aa20f 100644 --- a/tests/flow/union_new/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/union_new/__snapshots__/jsfmt.spec.js.snap @@ -1385,7 +1385,7 @@ function foo(c: C) { // annotations declare class C { - get(): X + get(): X; } function union(o: { x: string } | { x: number }) {} @@ -1431,8 +1431,8 @@ function foo(target: EventTarget) { } declare class EventTarget { - addEventListener(type: "foo", listener: KeyboardEventHandler): void, - addEventListener(type: string, listener: EventHandler): void + addEventListener(type: "foo", listener: KeyboardEventHandler): void; + addEventListener(type: string, listener: EventHandler): void; } declare class Event {} @@ -1530,8 +1530,8 @@ new C().m(f()); // method overloads declare class C { - m(x: number): void, - m(x: string): void + m(x: number): void; + m(x: string): void; } function f() { @@ -1565,8 +1565,8 @@ function m() { } declare class D { - constructor(_: void): void, - constructor(_: null): void + constructor(_: void): void; + constructor(_: null): void; } `; @@ -1759,15 +1759,15 @@ declare class D extends C { // scaling test for full type resolution declare class C { - addListener(event: string, listener: Function): C, - emit(event: string, ...args: Array): boolean, - listeners(event: string): Array, - listenerCount(event: string): number, - on(event: string, listener: Function): C, - once(event: string, listener: Function): C, - removeAllListeners(event?: string): C, - removeListener(event: string, listener: Function): C, - setMaxListeners(n: number): void + addListener(event: string, listener: Function): C; + emit(event: string, ...args: Array): boolean; + listeners(event: string): Array; + listenerCount(event: string): number; + on(event: string, listener: Function): C; + once(event: string, listener: Function): C; + removeAllListeners(event?: string): C; + removeListener(event: string, listener: Function): C; + setMaxListeners(n: number): void; } declare class D extends C { @@ -1776,16 +1776,16 @@ declare class D extends C { hostname?: string, backlog?: number, callback?: Function - ): D, - listen(path: string, callback?: Function): D, - listen(handle: Object, callback?: Function): D, - close(callback?: Function): D, - address(): number, - connections: number, - maxConnections: number, - getConnections(callback: Function): void, - ref(): D, - unref(): D + ): D; + listen(path: string, callback?: Function): D; + listen(handle: Object, callback?: Function): D; + close(callback?: Function): D; + address(): number; + connections: number; + maxConnections: number; + getConnections(callback: Function): void; + ref(): D; + unref(): D; } (0: D | number); @@ -1857,8 +1857,8 @@ declare var y: T; (foo(y): T); declare class Record { - set(x: "foo", y: number): void, - set(x: "bar", y: string): void + set(x: "foo", y: number): void; + set(x: "bar", y: string): void; } new Record().set("foo", "42"); @@ -1966,11 +1966,11 @@ declare class D { reduce( callbackfn: (previousValue: T, currentValue: T) => T, initialValue: void - ): T, + ): T; reduce( callbackfn: (previousValue: U, currentValue: T) => U, initialValue: U - ): U + ): U; } class C { @@ -2054,12 +2054,12 @@ function foo(): ImmutableMap { interface SomeIterator {} interface SomeIterable { - it(): SomeIterator + it(): SomeIterator; } declare class SomeMap { - it(): SomeIterator<[K, V]>, - set(k: K, v: V): void + it(): SomeIterator<[K, V]>; + set(k: K, v: V): void; } declare class ImmutableMap {} diff --git a/tests/flow/union_new/lib/__snapshots__/jsfmt.spec.js.snap b/tests/flow/union_new/lib/__snapshots__/jsfmt.spec.js.snap index 9e5bf12e8..b945fa2aa 100644 --- a/tests/flow/union_new/lib/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/union_new/lib/__snapshots__/jsfmt.spec.js.snap @@ -31,25 +31,25 @@ declare class Rows { } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ declare class Set { - add(x: any): Set + add(x: any): Set; } declare class Row { reduce_row( callbackfn: (previousValue: number, currentValue: number) => number, initialValue: void - ): number, + ): number; reduce_row( callbackfn: (previousValue: U, currentValue: number) => U, initialValue: U - ): U + ): U; } declare class Rows { reduce_rows( callbackfn: (previousValue: X, currentValue: Row) => X, initialValue: X - ): X + ): X; } `; diff --git a/tests/flow_function_parentheses/__snapshots__/jsfmt.spec.js.snap b/tests/flow_function_parentheses/__snapshots__/jsfmt.spec.js.snap index 36cc71ba6..f193c2ffb 100644 --- a/tests/flow_function_parentheses/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow_function_parentheses/__snapshots__/jsfmt.spec.js.snap @@ -120,7 +120,7 @@ class X { } interface F { - ideConnectionFactoryLongLongLong: child_process$ChildProcess => FlowIDEConnection + ideConnectionFactoryLongLongLong: child_process$ChildProcess => FlowIDEConnection; } type ExtractType = (B) => D; @@ -213,7 +213,7 @@ class X { } interface F { - ideConnectionFactoryLongLongLong: child_process$ChildProcess => FlowIDEConnection, + ideConnectionFactoryLongLongLong: child_process$ChildProcess => FlowIDEConnection; } type ExtractType = (B) => D; diff --git a/tests/flow_method/__snapshots__/jsfmt.spec.js.snap b/tests/flow_method/__snapshots__/jsfmt.spec.js.snap index 975277d58..476824044 100644 --- a/tests/flow_method/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow_method/__snapshots__/jsfmt.spec.js.snap @@ -36,8 +36,8 @@ declare function f(): void; var f: () => void; declare class X { - static deserialize(): mixed, - static deserialize: () => mixed + static deserialize(): mixed; + static deserialize: () => mixed; } `; diff --git a/tests/flow_union/__snapshots__/jsfmt.spec.js.snap b/tests/flow_union/__snapshots__/jsfmt.spec.js.snap index 8fbf7eff4..309e433ef 100644 --- a/tests/flow_union/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow_union/__snapshots__/jsfmt.spec.js.snap @@ -35,13 +35,13 @@ interface RelayProps { } | null> | null | void - | 1 + | 1; } interface RelayProps { articles: Array<{ __id: string - } | null> | null | void + } | null> | null | void; } export function aPrettyLongFunction( diff --git a/tests/interface/__snapshots__/jsfmt.spec.js.snap b/tests/interface/__snapshots__/jsfmt.spec.js.snap index 2d5eabaec..c9b5219d3 100644 --- a/tests/interface/__snapshots__/jsfmt.spec.js.snap +++ b/tests/interface/__snapshots__/jsfmt.spec.js.snap @@ -18,7 +18,7 @@ export class Environment2 extends GenericEnvironment< ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ export interface Environment1 extends GenericEnvironment { - m(): void + m(): void; } export class Environment2 extends GenericEnvironment< SomeType, diff --git a/tests/no-semi/__snapshots__/jsfmt.spec.js.snap b/tests/no-semi/__snapshots__/jsfmt.spec.js.snap index ff055a1b8..b9754ea02 100644 --- a/tests/no-semi/__snapshots__/jsfmt.spec.js.snap +++ b/tests/no-semi/__snapshots__/jsfmt.spec.js.snap @@ -81,6 +81,240 @@ x `; +exports[`flow-interfaces.js 1`] = ` +declare class A { + one: boolean; + two: { three: string } + | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// declare class B { +// one: boolean +// two: { three: string } +// | number +// } + +declare interface C { + one: boolean; + two: { three: string } + | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// declare interface D { +// one: boolean +// two: { three: string } +// | number +// } + +interface E { + one: boolean; + two: { three: string } + | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// interface F { +// one: boolean +// two: { three: string } +// | number +// } +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +declare class A { + one: boolean; + two: { three: string } | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// declare class B { +// one: boolean +// two: { three: string } +// | number +// } + +declare interface C { + one: boolean; + two: { three: string } | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// declare interface D { +// one: boolean +// two: { three: string } +// | number +// } + +interface E { + one: boolean; + two: { three: string } | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// interface F { +// one: boolean +// two: { three: string } +// | number +// } + +`; + +exports[`flow-interfaces.js 2`] = ` +declare class A { + one: boolean; + two: { three: string } + | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// declare class B { +// one: boolean +// two: { three: string } +// | number +// } + +declare interface C { + one: boolean; + two: { three: string } + | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// declare interface D { +// one: boolean +// two: { three: string } +// | number +// } + +interface E { + one: boolean; + two: { three: string } + | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// interface F { +// one: boolean +// two: { three: string } +// | number +// } +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +declare class A { + one: boolean; + two: { three: string } | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// declare class B { +// one: boolean +// two: { three: string } +// | number +// } + +declare interface C { + one: boolean; + two: { three: string } | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// declare interface D { +// one: boolean +// two: { three: string } +// | number +// } + +interface E { + one: boolean; + two: { three: string } | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// interface F { +// one: boolean +// two: { three: string } +// | number +// } + +`; + +exports[`flow-interfaces.js 3`] = ` +declare class A { + one: boolean; + two: { three: string } + | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// declare class B { +// one: boolean +// two: { three: string } +// | number +// } + +declare interface C { + one: boolean; + two: { three: string } + | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// declare interface D { +// one: boolean +// two: { three: string } +// | number +// } + +interface E { + one: boolean; + two: { three: string } + | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// interface F { +// one: boolean +// two: { three: string } +// | number +// } +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +declare class A { + one: boolean; + two: { three: string } | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// declare class B { +// one: boolean +// two: { three: string } +// | number +// } + +declare interface C { + one: boolean; + two: { three: string } | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// declare interface D { +// one: boolean +// two: { three: string } +// | number +// } + +interface E { + one: boolean; + two: { three: string } | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// interface F { +// one: boolean +// two: { three: string } +// | number +// } + +`; + exports[`issue2006.js 1`] = ` switch (n) { case 11: diff --git a/tests/no-semi/flow-interfaces.js b/tests/no-semi/flow-interfaces.js new file mode 100644 index 000000000..d3124db34 --- /dev/null +++ b/tests/no-semi/flow-interfaces.js @@ -0,0 +1,38 @@ +declare class A { + one: boolean; + two: { three: string } + | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// declare class B { +// one: boolean +// two: { three: string } +// | number +// } + +declare interface C { + one: boolean; + two: { three: string } + | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// declare interface D { +// one: boolean +// two: { three: string } +// | number +// } + +interface E { + one: boolean; + two: { three: string } + | number; +} + +// NOTE: Flow and Babylon both fail to apply ASI here +// interface F { +// one: boolean +// two: { three: string } +// | number +// } diff --git a/tests/rest/__snapshots__/jsfmt.spec.js.snap b/tests/rest/__snapshots__/jsfmt.spec.js.snap index 89de0451a..9e5d05071 100644 --- a/tests/rest/__snapshots__/jsfmt.spec.js.snap +++ b/tests/rest/__snapshots__/jsfmt.spec.js.snap @@ -25,7 +25,7 @@ declare class C { f( superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong, ...args - ): void, + ): void; } function f( @@ -36,7 +36,7 @@ function f( declare class C { f( ...superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong - ): void, + ): void; } [