From 898009ba66a1f31b5fea47f045f16e9d68fb7f0c Mon Sep 17 00:00:00 2001 From: James Long Date: Wed, 4 Jan 2017 16:52:49 -0500 Subject: [PATCH] Consistently print function parameters the correct way --- src/pp.js | 2 +- src/printer.js | 38 ++--- .../__snapshots__/jsfmt.spec.js.snap | 136 +++++++++++------- tests/dom/__snapshots__/jsfmt.spec.js.snap | 20 +-- tests/fetch/__snapshots__/jsfmt.spec.js.snap | 2 +- .../buffer/__snapshots__/jsfmt.spec.js.snap | 16 ++- .../__snapshots__/jsfmt.spec.js.snap | 42 ++++-- .../__snapshots__/jsfmt.spec.js.snap | 7 +- .../__snapshots__/jsfmt.spec.js.snap | 5 +- tests/react/__snapshots__/jsfmt.spec.js.snap | 14 +- tests/rec/__snapshots__/jsfmt.spec.js.snap | 4 +- tests/spread/__snapshots__/jsfmt.spec.js.snap | 6 +- tests/traces/__snapshots__/jsfmt.spec.js.snap | 4 +- .../libs/__snapshots__/jsfmt.spec.js.snap | 26 ++-- .../__snapshots__/jsfmt.spec.js.snap | 22 +-- .../lib/__snapshots__/jsfmt.spec.js.snap | 19 ++- 16 files changed, 217 insertions(+), 146 deletions(-) diff --git a/src/pp.js b/src/pp.js index 76d9ab9d..6383e35a 100644 --- a/src/pp.js +++ b/src/pp.js @@ -228,7 +228,7 @@ function print(w, doc) { } else { // Expanded states are a rare case where a document - // can manually provide mutliple representations of + // can manually provide multiple representations of // itself. It provides an array of documents // going from the least expanded (most flattened) // representation first to the most expanded. If a diff --git a/src/printer.js b/src/printer.js index 2bd1f9b8..024fd2a8 100644 --- a/src/printer.js +++ b/src/printer.js @@ -358,17 +358,7 @@ function genericPrintNoParens(path, options, print) { parts.push( path.call(print, "typeParameters"), - concat( - [ - "(", - indent( - options.tabWidth, - concat([ softline, printFunctionParams(path, print) ]) - ), - softline, - ")" - ] - ), + printFunctionParams(path, print, options), printReturnType(path, print), " ", path.call(print, "body") @@ -394,9 +384,7 @@ function genericPrintNoParens(path, options, print) { parts.push(path.call(print, "params", 0)); } else { parts.push( - "(", - printFunctionParams(path, print), - ")", + printFunctionParams(path, print, options), printReturnType(path, print) ); } @@ -1408,7 +1396,7 @@ else parts.push(path.call(print, "typeParameters")); - parts.push("(", printFunctionParams(path, print), ")"); + parts.push(printFunctionParams(path, print, options)); // The returnType is not wrapped in a TypeAnnotation, so the colon // needs to be added separately. @@ -1724,14 +1712,12 @@ function printMethod(path, options, print) { parts.push( key, path.call(print, "value", "typeParameters"), - "(", path.call( function(valuePath) { - return printFunctionParams(valuePath, print); + return printFunctionParams(valuePath, print, options); }, "value" ), - ")", path.call(p => printReturnType(p, print), "value"), " ", path.call(print, "value", "body") @@ -1771,7 +1757,7 @@ function printArgumentsList(path, options, print) { concat([ "(", join(concat([ ",", line ]), printed.slice(0, -1)), - ", ", + printed.length > 1 ? ", " : "", group(util.getLast(printed), { shouldBreak: true }), ")" ]), @@ -1807,7 +1793,7 @@ function printArgumentsList(path, options, print) { ); } -function printFunctionParams(path, print) { +function printFunctionParams(path, print, options) { var fun = path.getValue(); // namedTypes.Function.assert(fun); var printed = path.map(print, "params"); @@ -1830,7 +1816,15 @@ function printFunctionParams(path, print) { printed.push(concat([ "...", path.call(print, "rest") ])); } - return join(concat([ ",", line ]), printed); + return concat([ + "(", + indent( + options.tabWidth, + concat([ softline, join(concat([ ",", line ]), printed) ]) + ), + softline, + ")" + ]); } function printObjectMethod(path, options, print) { @@ -1858,9 +1852,7 @@ function printObjectMethod(path, options, print) { } parts.push( - "(", printFunctionParams(path, print), - ")", printReturnType(path, print), " ", path.call(print, "body") diff --git a/tests/disjoint-union-perf/__snapshots__/jsfmt.spec.js.snap b/tests/disjoint-union-perf/__snapshots__/jsfmt.spec.js.snap index 72753784..e693ccab 100644 --- a/tests/disjoint-union-perf/__snapshots__/jsfmt.spec.js.snap +++ b/tests/disjoint-union-perf/__snapshots__/jsfmt.spec.js.snap @@ -1250,68 +1250,102 @@ export const builders: { emptyStatement(): EmptyStatement; blockStatement(body: Statement[]): BlockStatement; expressionStatement(expression: Expression): ExpressionStatement; - ifStatement(test: Expression, - consequent: Statement, - alternate?: Statement): IfStatement; + ifStatement( + test: Expression, + consequent: Statement, + alternate?: Statement + ): IfStatement; breakStatement(label?: Identifier): BreakStatement; continueStatement(label?: Identifier): ContinueStatement; returnStatement(argument: ?Expression): ReturnStatement; throwStatement(argument: ?Expression): ThrowStatement; whileStatement(test: Expression, body: Statement): WhileStatement; - forStatement(init: ?(VariableDeclaration | Expression), - test: ?Expression, - update: ?Expression, - body: Statement): ForStatement; - forInStatement(left: VariableDeclaration | Expression, - right: Expression, - body: Statement): ForInStatement; - tryStatement(block: BlockStatement, - handler: ?CatchClause, - handlers: CatchClause[], - finalizer?: BlockStatement): TryStatement; - catchClause(param: Pattern, - guard: ?Expression, - body: BlockStatement): CatchClause; + forStatement( + init: ?(VariableDeclaration | Expression), + test: ?Expression, + update: ?Expression, + body: Statement + ): ForStatement; + forInStatement( + left: VariableDeclaration | Expression, + right: Expression, + body: Statement + ): ForInStatement; + tryStatement( + block: BlockStatement, + handler: ?CatchClause, + handlers: CatchClause[], + finalizer?: BlockStatement + ): TryStatement; + catchClause( + param: Pattern, + guard: ?Expression, + body: BlockStatement + ): CatchClause; identifier(name: string): Identifier; - literal(value: ?(string | boolean | number | RegExp), - regex?: { pattern: string; flags: string }): Literal; + literal( + value: ?(string | boolean | number | RegExp), + regex?: { pattern: string; flags: string } + ): Literal; thisExpression(): ThisExpression; arrayExpression(elements: Expression[]): ArrayExpression; objectExpreession(properties: Property[]): ObjectExpreession; - property(kind: \"init\" | \"get\" | \"set\", - key: Literal | Identifier, - value: Expression): Property; - functionExpression(id: ?Identifier, - params: Pattern[], - body: BlockStatement): FunctionExpression; - binaryExpression(operator: BinaryOperator, - left: Expression, - right: Expression): BinaryExpression; - unaryExpression(operator: UnaryOperator, - argument: Expression, - prefix: boolean): UnaryExpression; - assignmentExpression(operator: AssignmentOperator, - left: Pattern, - right: Expression): AssignmentExpression; - updateExpression(operator: UpdateOperator, - argument: Expression, - prefix: boolean): UpdateExpression; - logicalExpression(operator: LogicalOperator, - left: Expression, - right: Expression): LogicalExpression; - conditionalExpression(test: Expression, - consequent: Expression, - alternate: Expression): ConditionalExpression; + property( + kind: \"init\" | \"get\" | \"set\", + key: Literal | Identifier, + value: Expression + ): Property; + functionExpression( + id: ?Identifier, + params: Pattern[], + body: BlockStatement + ): FunctionExpression; + binaryExpression( + operator: BinaryOperator, + left: Expression, + right: Expression + ): BinaryExpression; + unaryExpression( + operator: UnaryOperator, + argument: Expression, + prefix: boolean + ): UnaryExpression; + assignmentExpression( + operator: AssignmentOperator, + left: Pattern, + right: Expression + ): AssignmentExpression; + updateExpression( + operator: UpdateOperator, + argument: Expression, + prefix: boolean + ): UpdateExpression; + logicalExpression( + operator: LogicalOperator, + left: Expression, + right: Expression + ): LogicalExpression; + conditionalExpression( + test: Expression, + consequent: Expression, + alternate: Expression + ): ConditionalExpression; newExpression(callee: Expression, arguments: Expression[]): NewExpression; callExpression(callee: Expression, arguments: Expression[]): CallExpression; - memberExpression(object: Expression, - property: Identifier | Expression, - computed: boolean): MemberExpression; - variableDeclaration(kind: \"var\" | \"let\" | \"const\", - declarations: VariableDeclarator[]): VariableDeclaration; - functionDeclaration(id: Identifier, - body: BlockStatement, - params: Pattern[]): FunctionDeclaration; + memberExpression( + object: Expression, + property: Identifier | Expression, + computed: boolean + ): MemberExpression; + variableDeclaration( + kind: \"var\" | \"let\" | \"const\", + declarations: VariableDeclarator[] + ): VariableDeclaration; + functionDeclaration( + id: Identifier, + body: BlockStatement, + params: Pattern[] + ): FunctionDeclaration; variableDeclarator(id: Pattern, init?: Expression): VariableDeclarator } = a; " diff --git a/tests/dom/__snapshots__/jsfmt.spec.js.snap b/tests/dom/__snapshots__/jsfmt.spec.js.snap index 52882397..fceb118c 100644 --- a/tests/dom/__snapshots__/jsfmt.spec.js.snap +++ b/tests/dom/__snapshots__/jsfmt.spec.js.snap @@ -469,20 +469,24 @@ let tests = [ createdCallback() {}, attachedCallback() {}, detachedCallback() {}, - attributeChangedCallback(attributeLocalName, - oldAttributeValue, - newAttributeValue, - attributeNamespace) {} + attributeChangedCallback( + attributeLocalName, + oldAttributeValue, + newAttributeValue, + attributeNamespace + ) {} }) }); }, function() { document.registerElement(\"custom-element\", { prototype: { - attributeChangedCallback(localName: string, - oldVal: string, - newVal: string, - namespace: string) {} + attributeChangedCallback( + localName: string, + oldVal: string, + newVal: string, + namespace: string + ) {} } }); } diff --git a/tests/fetch/__snapshots__/jsfmt.spec.js.snap b/tests/fetch/__snapshots__/jsfmt.spec.js.snap index 5781bd4d..bef18507 100644 --- a/tests/fetch/__snapshots__/jsfmt.spec.js.snap +++ b/tests/fetch/__snapshots__/jsfmt.spec.js.snap @@ -319,7 +319,7 @@ const h: Response = new Response(\"responsebody\", { status: 404, headers: new Headers({ \"Content-Type\": \"image/jpeg\" }) }); -const i: Response = new Response(, { +const i: Response = new Response({ status: 404, headers: new Headers({ \"Content-Type\": \"image/jpeg\" }) }); diff --git a/tests/node_tests/buffer/__snapshots__/jsfmt.spec.js.snap b/tests/node_tests/buffer/__snapshots__/jsfmt.spec.js.snap index e6b90a88..cc05c500 100644 --- a/tests/node_tests/buffer/__snapshots__/jsfmt.spec.js.snap +++ b/tests/node_tests/buffer/__snapshots__/jsfmt.spec.js.snap @@ -103,18 +103,22 @@ buffer = buffer.fill(\"a\", 0, 0, \"utf8\"); buffer = buffer.fill(\"a\", \"utf8\"); -maybeNum = buffer.find(, (element: number, -index: number, -array: Uint8Array) => false); +maybeNum = buffer.find(( + element: number, + index: number, + array: Uint8Array +) => false); maybeNum = buffer.find( (element: number, index: number, array: Uint8Array) => false, buffer ); -num = buffer.findIndex(, (element: number, -index: number, -array: Uint8Array) => false); +num = buffer.findIndex(( + element: number, + index: number, + array: Uint8Array +) => false); num = buffer.findIndex( (element: number, index: number, array: Uint8Array) => false, diff --git a/tests/predicates-abstract/__snapshots__/jsfmt.spec.js.snap b/tests/predicates-abstract/__snapshots__/jsfmt.spec.js.snap index fce50811..528f25c8 100644 --- a/tests/predicates-abstract/__snapshots__/jsfmt.spec.js.snap +++ b/tests/predicates-abstract/__snapshots__/jsfmt.spec.js.snap @@ -15,8 +15,10 @@ function is_string(x): %checks { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @flow // Filter the contents of an array -declare function my_filter>(v: Array, -cb: P): Array<$Refine>; +declare function my_filter>( + v: Array, + cb: P +): Array<$Refine>; declare var arr: Array; const barr = my_filter(arr, is_string); @@ -51,8 +53,10 @@ declare var ab: Array; // Filter the contents of an array // OK // OK -declare function my_filter>(v: Array, -cb: P): Array<$Refine>; +declare function my_filter>( + v: Array, + cb: P +): Array<$Refine>; type A = { kind: \"A\"; u: number }; type B = { kind: \"B\"; v: string }; type C = { kind: \"C\"; y: boolean }; @@ -140,9 +144,11 @@ var b = refine(a, is_string); (b: string); -declare function refine_fst>(v: T, -w: T, -cb: P): $Refine; +declare function refine_fst>( + v: T, + w: T, + cb: P +): $Refine; declare var c: mixed; declare var d: mixed; var e = refine2(c, d, is_string_and_number); @@ -188,8 +194,10 @@ function is_string_regular(x): boolean { // @flow // Sanity check A: filtering the wrong type // Sanity check B: Passing non-predicate function to filter -declare function my_filter>(v: Array, -cb: P): Array<$Refine>; +declare function my_filter>( + v: Array, + cb: P +): Array<$Refine>; declare var a: Array; const b = my_filter(a, is_string); @@ -233,8 +241,10 @@ declare var ab: Array; // Filter the contents of an array // ERROR // ERROR -declare function my_filter>(v: Array, -cb: P): Array<$Refine>; +declare function my_filter>( + v: Array, + cb: P +): Array<$Refine>; type A = { kind: \"A\"; u: number }; type B = { kind: \"B\"; v: string }; type C = { kind: \"C\"; y: boolean }; @@ -312,10 +322,12 @@ var b = refine(a, is_string); declare var c: mixed; declare var d: mixed; declare var e: mixed; -declare function refine3>(u: T, -v: T, -w: T, -cb: P): $Refine; +declare function refine3>( + u: T, + v: T, + w: T, + cb: P +): $Refine; var e = refine3(c, d, e, is_string_and_number); (e: string); diff --git a/tests/predicates-declared/__snapshots__/jsfmt.spec.js.snap b/tests/predicates-declared/__snapshots__/jsfmt.spec.js.snap index 4a69f082..d7d0a6a4 100644 --- a/tests/predicates-declared/__snapshots__/jsfmt.spec.js.snap +++ b/tests/predicates-declared/__snapshots__/jsfmt.spec.js.snap @@ -400,9 +400,10 @@ foo(3, 3); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @flow // Sanity check: make sure the parameters are checked as usual -declare function foo(input: mixed, -types: string | Array): boolean %checks(typeof input === \"string\" || - Array.isArray(input)); +declare function foo( + input: mixed, + types: string | Array +): boolean %checks(typeof input === \"string\" || Array.isArray(input)); foo(3, 3); " diff --git a/tests/predicates-parsing/__snapshots__/jsfmt.spec.js.snap b/tests/predicates-parsing/__snapshots__/jsfmt.spec.js.snap index 1b518ad8..16757c5a 100644 --- a/tests/predicates-parsing/__snapshots__/jsfmt.spec.js.snap +++ b/tests/predicates-parsing/__snapshots__/jsfmt.spec.js.snap @@ -102,8 +102,9 @@ var a1 = (x: mixed): %checks => x !== null; (x): %checks => x !== null; -const insert_a_really_big_predicated_arrow_function_name_here = (x): %checks => x !== - null; +const insert_a_really_big_predicated_arrow_function_name_here = ( + x +): %checks => x !== null; declare var x; x; diff --git a/tests/react/__snapshots__/jsfmt.spec.js.snap b/tests/react/__snapshots__/jsfmt.spec.js.snap index 66376386..3a399dec 100644 --- a/tests/react/__snapshots__/jsfmt.spec.js.snap +++ b/tests/react/__snapshots__/jsfmt.spec.js.snap @@ -129,7 +129,7 @@ var blah = ; // error bar, number given string expected /* @flow */ // error bar, number given string expected var React = require(\"react\"); -var Foo = React.createClass(, { +var Foo = React.createClass({ propTypes: { bar: React.PropTypes.string.isRequired } }); var props = { bar: 42 }; @@ -155,7 +155,7 @@ var fail_mistyped_elems = ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ var React = require(\"react\"); -var Example = React.createClass(, { +var Example = React.createClass({ propTypes: { arr: React.PropTypes.arrayOf(React.PropTypes.number).isRequired } }); var ok_empty = ; @@ -183,7 +183,7 @@ var fail_mistyped = ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ var React = require(\"react\"); -var Example = React.createClass(, { +var Example = React.createClass({ propTypes: { func: React.PropTypes.func.isRequired } }); var ok_void = {}}/>; @@ -275,7 +275,7 @@ var fail_mistyped = ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ var React = require(\"react\"); -var Example = React.createClass(, { +var Example = React.createClass({ propTypes: { object: React.PropTypes.object.isRequired } }); var ok_empty = ; @@ -302,7 +302,7 @@ var fail_mistyped_props = ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ var React = require(\"react\"); -var Example = React.createClass(, { +var Example = React.createClass({ propTypes: { obj: React.PropTypes.objectOf(React.PropTypes.number).isRequired } @@ -329,7 +329,7 @@ var ex2 = ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ var React = require(\"react\"); -var Example = React.createClass(, { +var Example = React.createClass({ propTypes: { literal: React.PropTypes.oneOf([ \"foo\" ]).isRequired } }); var ex1 = ; @@ -366,7 +366,7 @@ var fail_bool = var React = require(\"react\"); var Example = React.createClass({ propTypes: { - prop: React.PropTypes.oneOfType(, [ + prop: React.PropTypes.oneOfType([ React.PropTypes.string, React.PropTypes.number ]).isRequired diff --git a/tests/rec/__snapshots__/jsfmt.spec.js.snap b/tests/rec/__snapshots__/jsfmt.spec.js.snap index 9cd0adff..58fec505 100644 --- a/tests/rec/__snapshots__/jsfmt.spec.js.snap +++ b/tests/rec/__snapshots__/jsfmt.spec.js.snap @@ -61,7 +61,9 @@ function id(x: Task): Task { return x; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ type Task = { - chain(next: (input: value) => Task): Task + chain( + next: (input: value) => Task + ): Task }; function id(x: Task): Task { diff --git a/tests/spread/__snapshots__/jsfmt.spec.js.snap b/tests/spread/__snapshots__/jsfmt.spec.js.snap index 4cea1ab5..9737b706 100644 --- a/tests/spread/__snapshots__/jsfmt.spec.js.snap +++ b/tests/spread/__snapshots__/jsfmt.spec.js.snap @@ -160,8 +160,10 @@ function test( * result is a new object. */ // OK -declare function map(obj: { [key: string]: Tv }, -iterator: (obj: Tv) => TNext): Array; +declare function map( + obj: { [key: string]: Tv }, + iterator: (obj: Tv) => TNext +): Array; function test( x: { kind: ?string }, diff --git a/tests/traces/__snapshots__/jsfmt.spec.js.snap b/tests/traces/__snapshots__/jsfmt.spec.js.snap index 6ea04f73..e20570a8 100644 --- a/tests/traces/__snapshots__/jsfmt.spec.js.snap +++ b/tests/traces/__snapshots__/jsfmt.spec.js.snap @@ -87,10 +87,10 @@ function f(b): React.Element<*> { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @flow var React = require(\"react\"); -var A = React.createClass(, { +var A = React.createClass({ propTypes: { foo: React.PropTypes.string.isRequired } }); -var B = React.createClass(, { +var B = React.createClass({ propTypes: { bar: React.PropTypes.string.isRequired } }); diff --git a/tests/type_param_variance2/libs/__snapshots__/jsfmt.spec.js.snap b/tests/type_param_variance2/libs/__snapshots__/jsfmt.spec.js.snap index 1a9e0152..398ba6c4 100644 --- a/tests/type_param_variance2/libs/__snapshots__/jsfmt.spec.js.snap +++ b/tests/type_param_variance2/libs/__snapshots__/jsfmt.spec.js.snap @@ -55,12 +55,20 @@ declare class Promise { // library files declared earlier, including default flow libs. // Non-standard APIs declare class Promise { - constructor(callback: (resolve: (result?: Promise | R) => void, - reject: (error?: any) => void) => void): void; - then(onFulfill?: ?(value: R) => Promise | ?U, - onReject?: ?(error: any) => Promise | ?U): Promise; - done(onFulfill?: ?(value: R) => void, - onReject?: ?(error: any) => void): void; + constructor( + callback: ( + resolve: (result?: Promise | R) => void, + reject: (error?: any) => void + ) => void + ): void; + then( + onFulfill?: ?(value: R) => Promise | ?U, + onReject?: ?(error: any) => Promise | ?U + ): Promise; + done( + onFulfill?: ?(value: R) => void, + onReject?: ?(error: any) => void + ): void; catch(onReject?: (error: any) => ?Promise | U): Promise; static resolve(object?: Promise | T): Promise; static reject(error?: any): Promise; @@ -68,9 +76,9 @@ declare class 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 - }> + static allObject( + promisesByKey: T + ): Promise<{ [key: $Keys]: any }> } " `; diff --git a/tests/union_new/__snapshots__/jsfmt.spec.js.snap b/tests/union_new/__snapshots__/jsfmt.spec.js.snap index 4a0be04b..d94fa137 100644 --- a/tests/union_new/__snapshots__/jsfmt.spec.js.snap +++ b/tests/union_new/__snapshots__/jsfmt.spec.js.snap @@ -1626,10 +1626,12 @@ declare class C { setMaxListeners(n: number): void } declare class D extends C { - listen(port: number, - hostname?: string, - backlog?: number, - callback?: Function): D; + listen( + port: number, + hostname?: string, + backlog?: number, + callback?: Function + ): D; listen(path: string, callback?: Function): D; listen(handle: Object, callback?: Function): D; close(callback?: Function): D; @@ -1812,10 +1814,14 @@ class C { // with different instantiations. type Row = { x: string }; declare class D { - reduce(callbackfn: (previousValue: T, currentValue: T) => T, - initialValue: void): T; - reduce(callbackfn: (previousValue: U, currentValue: T) => U, - initialValue: U): U + reduce( + callbackfn: (previousValue: T, currentValue: T) => T, + initialValue: void + ): T; + reduce( + callbackfn: (previousValue: U, currentValue: T) => U, + initialValue: U + ): U } class C { foo(rows: D, minWidth: number): number { diff --git a/tests/union_new/lib/__snapshots__/jsfmt.spec.js.snap b/tests/union_new/lib/__snapshots__/jsfmt.spec.js.snap index bd8363a1..c25263f5 100644 --- a/tests/union_new/lib/__snapshots__/jsfmt.spec.js.snap +++ b/tests/union_new/lib/__snapshots__/jsfmt.spec.js.snap @@ -30,15 +30,20 @@ declare class Rows { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ declare class Set { add(): Set } declare class Row { - reduce_row(callbackfn: (previousValue: number, - currentValue: number) => number, - initialValue: void): number; - reduce_row(callbackfn: (previousValue: U, currentValue: number) => U, - initialValue: U): U + reduce_row( + callbackfn: (previousValue: number, currentValue: number) => number, + initialValue: void + ): number; + reduce_row( + callbackfn: (previousValue: U, currentValue: number) => U, + initialValue: U + ): U } declare class Rows { - reduce_rows(callbackfn: (previousValue: X, currentValue: Row) => X, - initialValue: X): X + reduce_rows( + callbackfn: (previousValue: X, currentValue: Row) => X, + initialValue: X + ): X } " `;