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