Remove whitespace generation (#5833)

* Remove whitespace generation and rely on default printing

Changes to printing:
* Add newline after last empty SwitchCase
* Add newlines around block comments if they are non-flow comments or contain newlines

* Fix a few more fixtures
This commit is contained in:
Daniel Tschinder
2017-06-27 19:57:02 -07:00
committed by Brian Ng
parent bc29145465
commit b3372a572d
379 changed files with 1974 additions and 1109 deletions

View File

@@ -1 +1,3 @@
const x = (foo /*:: ?*/) => {};
const x = (foo
/*:: ?*/
) => {};

View File

@@ -1 +1,3 @@
const x = (foo /*: string*/) => {};
const x = (foo
/*: string*/
) => {};

View File

@@ -1,4 +1,6 @@
class X {
/*:: a: number*/
/*:: b: ?string*/
}
}

View File

@@ -1,5 +1,9 @@
class X {
foo = 2;
bar /*: number*/ = 3;
bar
/*: number*/
= 3;
/*:: baz: ?string*/
}
}

View File

@@ -1,16 +1,31 @@
/*:: declare var foo*/
/*:: declare var foo;*/
/*:: declare function foo(): void*/
/*:: declare function foo(): void;*/
/*:: declare function foo<T>(): void;*/
/*:: declare function foo(x: number, y: string): void;*/
/*:: declare class A {}*/
/*:: declare class A<T> extends B<T> { x: number }*/
/*:: declare class A { static foo(): number, static x : string }*/
/*:: declare class A { static [ indexer: number]: string }*/
/*:: declare class A { static () : number }*/
/*:: declare class A mixins B<T>, C {}*/
/*:: declare type A = string*/
/*:: declare type T<U> = { [k:string]: U }*/
/*:: declare interface I { foo: string }*/
/*:: declare interface I<T> { foo: T }*/
/*:: declare interface I<T> { foo: T }*/

View File

@@ -1,3 +1,9 @@
class C /*:: <+T, -U>*/ {}
function f /*:: <+T, -U>*/() {}
/*:: type T<+T, -U> = {};*/
class C
/*:: <+T, -U>*/
{}
function f
/*:: <+T, -U>*/
() {}
/*:: type T<+T, -U> = {};*/

View File

@@ -1,6 +1,23 @@
function foo(numVal /*:: ?*/) {}
function foo(numVal /*:: ?*/ = 2) {}
function foo(numVal /*: number*/) {}
function foo(numVal /*:: ?: number*/) {}
function foo(numVal /*: number*/ = 2) {}
function foo(numVal /*:: ?: number*/ = 2) {}
function foo(numVal
/*:: ?*/
) {}
function foo(numVal
/*:: ?*/
= 2) {}
function foo(numVal
/*: number*/
) {}
function foo(numVal
/*:: ?: number*/
) {}
function foo(numVal
/*: number*/
= 2) {}
function foo(numVal
/*:: ?: number*/
= 2) {}

View File

@@ -1,4 +1,5 @@
/*:: export type GraphQLFormattedError = number;*/
/*:: export type GraphQLFormattedError = {
message: string,
locations?: Array<{
@@ -6,5 +7,7 @@
column: number
}>
};*/
/*:: export interface foo { p: number }*/
/*:: export interface foo<T> { p: T }*/
/*:: export interface foo<T> { p: T }*/

View File

@@ -1,4 +1,4 @@
import lib from 'library';
export { foo } from 'foo';
/*:: export type { B, C } from './types';*/
/*:: export type { B, C } from './types';*/

View File

@@ -1,3 +1,5 @@
import lib from 'library';
/*:: import type A, { B, C } from './types';*/
/*:: import typeof D, { E, F } from './types';*/
/*:: import typeof D, { E, F } from './types';*/

View File

@@ -1,6 +1,10 @@
// @flow
var obj = {
method: function (a /*: string*/) /*: number*/ {
method: function (a
/*: string*/
)
/*: number*/
{
return 5 + 5;
}
};
};

View File

@@ -1 +1,3 @@
function multiply(num /*:: ?: number*/) {}
function multiply(num
/*:: ?: number*/
) {}

View File

@@ -1,2 +1,7 @@
function foo(bar /*:: ?*/) {}
function foo2(bar /*:: ?: string*/) {}
function foo(bar
/*:: ?*/
) {}
function foo2(bar
/*:: ?: string*/
) {}

View File

@@ -4,7 +4,11 @@
var C = function () {
function C() {}
C.prototype.m = function m(x /*: number*/) /*: string*/ {
C.prototype.m = function m(x
/*: number*/
)
/*: string*/
{
return 'a';
};

View File

@@ -8,7 +8,11 @@ var C = function () {
babelHelpers.createClass(C, [{
key: "m",
value: function m(x /*: number*/) /*: string*/ {
value: function m(x
/*: number*/
)
/*: string*/
{
return 'a';
}
}]);

View File

@@ -1,6 +1,8 @@
/*:: type T = /*test*-/ number;*/
/*:: type T2 = /* *-ESCAPED/ *-/ number;*/
/*:: type CustomType = {
/** This is some documentation. *-/
name: string;
};*/
};*/

View File

@@ -1,13 +1,17 @@
function a() {}
/*:: type A = number;*/
/*:: type B = {
name: string;
};*/
/*:: type union =
| {type: "A"}
| {type: "B"}
;*/
/*:: type overloads =
& ((x: string) => number)
& ((x: number) => string)
;*/
;*/

View File

@@ -1,2 +1,8 @@
var a = (y /*: any*/);
var a = ((y /*: foo*/) /*: any*/);
var a = (y
/*: any*/
);
var a = ((y
/*: foo*/
)
/*: any*/
);

View File

@@ -1 +1,5 @@
function foo(x /*: number*/) /*: string*/ {}
function foo(x
/*: number*/
)
/*: string*/
{}