2017-02-21 13:59:19 -08:00
|
|
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
|
|
2020-04-10 19:12:01 +08:00
|
|
|
exports[`array.js format 1`] = `
|
2018-11-25 16:21:14 +08:00
|
|
|
====================================options=====================================
|
|
|
|
|
parsers: ["flow"]
|
|
|
|
|
printWidth: 80
|
|
|
|
|
| printWidth
|
|
|
|
|
=====================================input======================================
|
2016-12-27 21:40:04 -05:00
|
|
|
// @flow
|
2017-01-09 21:49:06 -05:00
|
|
|
|
2016-12-27 21:40:04 -05:00
|
|
|
type Foo = {};
|
|
|
|
|
var f: Foo = {};
|
2017-01-24 11:38:12 -08:00
|
|
|
export var arr = [f];
|
2017-04-12 13:41:51 -07:00
|
|
|
|
2018-11-25 16:21:14 +08:00
|
|
|
=====================================output=====================================
|
2017-04-12 13:41:51 -07:00
|
|
|
// @flow
|
2016-12-27 21:40:04 -05:00
|
|
|
|
2018-11-25 16:21:14 +08:00
|
|
|
type Foo = {};
|
|
|
|
|
var f: Foo = {};
|
|
|
|
|
export var arr = [f];
|
|
|
|
|
|
|
|
|
|
================================================================================
|
|
|
|
|
`;
|
|
|
|
|
|
2020-04-10 19:12:01 +08:00
|
|
|
exports[`async_return.js format 1`] = `
|
2018-11-25 16:21:14 +08:00
|
|
|
====================================options=====================================
|
|
|
|
|
parsers: ["flow"]
|
|
|
|
|
printWidth: 80
|
|
|
|
|
| printWidth
|
|
|
|
|
=====================================input======================================
|
2016-12-27 21:40:04 -05:00
|
|
|
// @flow
|
2017-01-09 21:49:06 -05:00
|
|
|
|
2016-12-27 21:40:04 -05:00
|
|
|
export async function foo() {
|
|
|
|
|
return 123;
|
2017-01-11 10:16:38 -05:00
|
|
|
}
|
2017-04-12 13:41:51 -07:00
|
|
|
|
2018-11-25 16:21:14 +08:00
|
|
|
=====================================output=====================================
|
|
|
|
|
// @flow
|
|
|
|
|
|
|
|
|
|
export async function foo() {
|
|
|
|
|
return 123;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
================================================================================
|
2016-12-27 21:40:04 -05:00
|
|
|
`;
|
|
|
|
|
|
2020-04-10 19:12:01 +08:00
|
|
|
exports[`infer.js format 1`] = `
|
2018-11-25 16:21:14 +08:00
|
|
|
====================================options=====================================
|
|
|
|
|
parsers: ["flow"]
|
|
|
|
|
printWidth: 80
|
|
|
|
|
| printWidth
|
|
|
|
|
=====================================input======================================
|
2017-04-12 13:41:51 -07:00
|
|
|
/* @flow */
|
2016-12-27 21:40:04 -05:00
|
|
|
|
|
|
|
|
var Foo = {
|
|
|
|
|
a: function(arg) { // missing arg annotation
|
|
|
|
|
return arg;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
b: function(arg) { // missing arg annotation
|
|
|
|
|
return {
|
|
|
|
|
bar: arg
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
c: function(arg: string) { // no return annotation required
|
|
|
|
|
return {
|
|
|
|
|
bar: arg
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
d: function(arg: string): {
|
|
|
|
|
bar: string
|
|
|
|
|
} {
|
|
|
|
|
return {
|
|
|
|
|
bar: arg
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// return type annotation may be omitted, but if so, input positions on
|
|
|
|
|
// observed return type (e.g. param types in a function type) must come
|
|
|
|
|
// from annotations
|
|
|
|
|
e: function(arg: string) {
|
|
|
|
|
return function(x) { // missing param annotation
|
|
|
|
|
return x;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// ...if the return type is annotated explicitly, this is unnecessary
|
|
|
|
|
f: function(arg: string): (x:number) => number {
|
|
|
|
|
return function(x) { // no error
|
|
|
|
|
return x;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var Bar = {
|
2017-02-21 13:59:19 -08:00
|
|
|
a: Foo.a('Foo'), // no annotation required
|
2016-12-27 21:40:04 -05:00
|
|
|
|
2017-02-21 13:59:19 -08:00
|
|
|
// object property types are inferred, so make sure that this doesn't cause
|
|
|
|
|
// us to also infer the parameter's type.
|
|
|
|
|
b: Foo.b('bar'), // no annotation required
|
2016-12-27 21:40:04 -05:00
|
|
|
|
2017-02-21 13:59:19 -08:00
|
|
|
c: Foo.c('bar'), // no annotation required
|
2016-12-27 21:40:04 -05:00
|
|
|
|
2017-02-21 13:59:19 -08:00
|
|
|
d: Foo.d('bar'), // no annotation required
|
2016-12-27 21:40:04 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = Foo, Bar;
|
2018-11-25 16:21:14 +08:00
|
|
|
|
|
|
|
|
=====================================output=====================================
|
2016-12-27 21:40:04 -05:00
|
|
|
/* @flow */
|
2017-01-09 21:49:06 -05:00
|
|
|
|
2016-12-27 21:40:04 -05:00
|
|
|
var Foo = {
|
2020-01-20 09:26:47 -05:00
|
|
|
a: function (arg) {
|
2017-02-03 13:56:06 -08:00
|
|
|
// missing arg annotation
|
2016-12-27 21:40:04 -05:00
|
|
|
return arg;
|
|
|
|
|
},
|
2017-02-09 08:08:58 -08:00
|
|
|
|
2020-01-20 09:26:47 -05:00
|
|
|
b: function (arg) {
|
2017-02-03 13:56:06 -08:00
|
|
|
// missing arg annotation
|
2017-01-30 09:08:55 -08:00
|
|
|
return {
|
2019-11-18 18:39:12 +08:00
|
|
|
bar: arg,
|
2017-01-30 09:08:55 -08:00
|
|
|
};
|
2016-12-27 21:40:04 -05:00
|
|
|
},
|
2017-02-09 08:08:58 -08:00
|
|
|
|
2020-01-20 09:26:47 -05:00
|
|
|
c: function (arg: string) {
|
2017-02-03 13:56:06 -08:00
|
|
|
// no return annotation required
|
2017-01-30 09:08:55 -08:00
|
|
|
return {
|
2019-11-18 18:39:12 +08:00
|
|
|
bar: arg,
|
2017-01-30 09:08:55 -08:00
|
|
|
};
|
2016-12-27 21:40:04 -05:00
|
|
|
},
|
2017-02-09 08:08:58 -08:00
|
|
|
|
2021-02-23 16:38:56 +02:00
|
|
|
d: function (arg: string): {
|
2019-11-18 18:39:12 +08:00
|
|
|
bar: string,
|
2017-01-30 09:08:55 -08:00
|
|
|
} {
|
|
|
|
|
return {
|
2019-11-18 18:39:12 +08:00
|
|
|
bar: arg,
|
2017-01-30 09:08:55 -08:00
|
|
|
};
|
2016-12-27 21:40:04 -05:00
|
|
|
},
|
2017-02-09 08:08:58 -08:00
|
|
|
|
2017-01-09 21:49:06 -05:00
|
|
|
// return type annotation may be omitted, but if so, input positions on
|
|
|
|
|
// observed return type (e.g. param types in a function type) must come
|
|
|
|
|
// from annotations
|
2020-01-20 09:26:47 -05:00
|
|
|
e: function (arg: string) {
|
|
|
|
|
return function (x) {
|
2017-02-03 13:56:06 -08:00
|
|
|
// missing param annotation
|
2016-12-27 21:40:04 -05:00
|
|
|
return x;
|
|
|
|
|
};
|
|
|
|
|
},
|
2017-02-09 08:08:58 -08:00
|
|
|
|
2017-01-09 21:49:06 -05:00
|
|
|
// ...if the return type is annotated explicitly, this is unnecessary
|
2020-01-20 09:26:47 -05:00
|
|
|
f: function (arg: string): (x: number) => number {
|
|
|
|
|
return function (x) {
|
2017-02-03 13:56:06 -08:00
|
|
|
// no error
|
2016-12-27 21:40:04 -05:00
|
|
|
return x;
|
|
|
|
|
};
|
2019-11-18 18:39:12 +08:00
|
|
|
},
|
2016-12-27 21:40:04 -05:00
|
|
|
};
|
2017-01-09 21:49:06 -05:00
|
|
|
|
2016-12-27 21:40:04 -05:00
|
|
|
var Bar = {
|
2017-04-12 13:41:51 -07:00
|
|
|
a: Foo.a("Foo"), // no annotation required
|
2017-02-09 08:08:58 -08:00
|
|
|
|
2017-02-21 13:59:19 -08:00
|
|
|
// object property types are inferred, so make sure that this doesn't cause
|
|
|
|
|
// us to also infer the parameter's type.
|
2017-04-12 13:41:51 -07:00
|
|
|
b: Foo.b("bar"), // no annotation required
|
2017-02-09 08:08:58 -08:00
|
|
|
|
2017-04-12 13:41:51 -07:00
|
|
|
c: Foo.c("bar"), // no annotation required
|
2017-02-09 08:08:58 -08:00
|
|
|
|
2019-11-18 18:39:12 +08:00
|
|
|
d: Foo.d("bar"), // no annotation required
|
2016-12-27 21:40:04 -05:00
|
|
|
};
|
2017-01-09 21:49:06 -05:00
|
|
|
|
2017-03-03 13:46:11 -08:00
|
|
|
(module.exports = Foo), Bar;
|
2017-04-12 13:41:51 -07:00
|
|
|
|
2018-11-25 16:21:14 +08:00
|
|
|
================================================================================
|
2016-12-27 21:40:04 -05:00
|
|
|
`;
|