241 lines
5.0 KiB
Plaintext
241 lines
5.0 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`any.js 1`] = `
|
|
"// @flow
|
|
|
|
function foo(x:any):any { return x; }
|
|
function bar(x:any):mixed { return x; }
|
|
function qux(x:mixed):any { return x; }
|
|
|
|
var x:string = foo(0);
|
|
var y:string = bar(0);
|
|
var z:string = qux(0);
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// @flow
|
|
|
|
function foo(x: any): any {
|
|
return x;
|
|
}
|
|
function bar(x: any): mixed {
|
|
return x;
|
|
}
|
|
function qux(x: mixed): any {
|
|
return x;
|
|
}
|
|
|
|
var x: string = foo(0);
|
|
var y: string = bar(0);
|
|
var z: string = qux(0);
|
|
"
|
|
`;
|
|
|
|
exports[`anyexportflowfile.js 1`] = `
|
|
"// @flow
|
|
|
|
module.exports = ((x: any) => x: any);
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// @flow
|
|
|
|
module.exports = ((x: any) => x: any);
|
|
"
|
|
`;
|
|
|
|
exports[`flowfixme.js 1`] = `
|
|
"/*
|
|
FlowFixMe is a synonym for any, used by the Flow team to
|
|
signal a needed mod to JS devs.
|
|
|
|
@flow
|
|
*/
|
|
|
|
// no param
|
|
function foo(x:$FlowFixMe):$FlowFixMe { return x; }
|
|
function bar(x:$FlowFixMe):mixed { return x; }
|
|
// param (info only)
|
|
function qux(x:$FlowFixMe<number>):$FlowFixMe<number> { return x; }
|
|
// ...params are still checked. unknown type
|
|
function baz(x:$FlowFixMe<nnumber>): $FlowFixMe<number> { return x; }
|
|
|
|
var x:string = foo(0);
|
|
var y:string = bar(0);
|
|
var z:string = qux(0);
|
|
var w:string = baz(0);
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/*
|
|
FlowFixMe is a synonym for any, used by the Flow team to
|
|
signal a needed mod to JS devs.
|
|
|
|
@flow
|
|
*/
|
|
|
|
// no param
|
|
function foo(x: $FlowFixMe): $FlowFixMe {
|
|
return x;
|
|
}
|
|
function bar(x: $FlowFixMe): mixed {
|
|
return x;
|
|
}
|
|
// param (info only)
|
|
function qux(x: $FlowFixMe<number>): $FlowFixMe<number> {
|
|
return x;
|
|
}
|
|
// ...params are still checked. unknown type
|
|
function baz(x: $FlowFixMe<nnumber>): $FlowFixMe<number> {
|
|
return x;
|
|
}
|
|
|
|
var x: string = foo(0);
|
|
var y: string = bar(0);
|
|
var z: string = qux(0);
|
|
var w: string = baz(0);
|
|
"
|
|
`;
|
|
|
|
exports[`flowissue.js 1`] = `
|
|
"/*
|
|
$FlowIssue is a synonym for any, used by JS devs to signal
|
|
a potential typechecker bug to the Flow team.
|
|
|
|
@flow
|
|
*/
|
|
|
|
// no param
|
|
function foo(x:$FlowIssue):$FlowIssue { return x; }
|
|
function bar(x:$FlowIssue):mixed { return x; }
|
|
// param (info only)
|
|
function qux(x:$FlowIssue<number>):$FlowIssue<number> { return x; }
|
|
// ...params are still checked. unknown type
|
|
function baz(x:$FlowIssue<nnumber>): $FlowIssue<number> { return x; }
|
|
|
|
var x:string = foo(0);
|
|
var y:string = bar(0);
|
|
var z:string = qux(0);
|
|
var w:string = baz(0);
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/*
|
|
$FlowIssue is a synonym for any, used by JS devs to signal
|
|
a potential typechecker bug to the Flow team.
|
|
|
|
@flow
|
|
*/
|
|
|
|
// no param
|
|
function foo(x: $FlowIssue): $FlowIssue {
|
|
return x;
|
|
}
|
|
function bar(x: $FlowIssue): mixed {
|
|
return x;
|
|
}
|
|
// param (info only)
|
|
function qux(x: $FlowIssue<number>): $FlowIssue<number> {
|
|
return x;
|
|
}
|
|
// ...params are still checked. unknown type
|
|
function baz(x: $FlowIssue<nnumber>): $FlowIssue<number> {
|
|
return x;
|
|
}
|
|
|
|
var x: string = foo(0);
|
|
var y: string = bar(0);
|
|
var z: string = qux(0);
|
|
var w: string = baz(0);
|
|
"
|
|
`;
|
|
|
|
exports[`nonflowfile.js 1`] = `
|
|
"// @noflow
|
|
|
|
module.exports = (x) => x;
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// @noflow
|
|
|
|
module.exports = x => x;
|
|
"
|
|
`;
|
|
|
|
exports[`propagate.js 1`] = `
|
|
"// @flow
|
|
|
|
declare class C {
|
|
bar(n1: number, n2: number): number;
|
|
bar(s1: string, s2: string): string;
|
|
}
|
|
|
|
function foo(c: C, x: any): string {
|
|
let y = x.y;
|
|
return c.bar(0, y); // should be able to select first case and error
|
|
}
|
|
|
|
var any_fun1 = require('./nonflowfile');
|
|
function bar1(x: mixed) {
|
|
if (any_fun1(x)) {
|
|
(x: boolean);
|
|
}
|
|
}
|
|
|
|
var any_fun2 = require('./anyexportflowfile');
|
|
function bar2(x: mixed) {
|
|
if (any_fun2(x)) {
|
|
(x: boolean);
|
|
}
|
|
}
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// @flow
|
|
|
|
declare class C {
|
|
bar(n1: number, n2: number): number,
|
|
bar(s1: string, s2: string): string
|
|
}
|
|
|
|
function foo(c: C, x: any): string {
|
|
let y = x.y;
|
|
return c.bar(0, y); // should be able to select first case and error
|
|
}
|
|
|
|
var any_fun1 = require(\\"./nonflowfile\\");
|
|
function bar1(x: mixed) {
|
|
if (any_fun1(x)) {
|
|
(x: boolean);
|
|
}
|
|
}
|
|
|
|
var any_fun2 = require(\\"./anyexportflowfile\\");
|
|
function bar2(x: mixed) {
|
|
if (any_fun2(x)) {
|
|
(x: boolean);
|
|
}
|
|
}
|
|
"
|
|
`;
|
|
|
|
exports[`reach.js 1`] = `
|
|
"/**
|
|
* like class and function values, any-typed values may be used in
|
|
* type annotations. Here we test propagation of any through the
|
|
* annotation - without it, the body of the if will be unreachable
|
|
*/
|
|
|
|
type AsyncRequest = any;
|
|
|
|
function foo(o: ?AsyncRequest) {
|
|
if (o) {
|
|
var n: number = o;
|
|
}
|
|
}
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/**
|
|
* like class and function values, any-typed values may be used in
|
|
* type annotations. Here we test propagation of any through the
|
|
* annotation - without it, the body of the if will be unreachable
|
|
*/
|
|
|
|
type AsyncRequest = any;
|
|
|
|
function foo(o: ?AsyncRequest) {
|
|
if (o) {
|
|
var n: number = o;
|
|
}
|
|
}
|
|
"
|
|
`;
|