可以对无点函数进行流注释吗?
Possible to flow-annotate a point-free function?
鉴于这些类型:
type Bar = number;
type Foo = {
bar: Bar,
};
还有这个无积分转换函数fooToBar
:
import { prop } from 'ramda';
const fooToBar = prop('bar');
是否可以注释 fooToBar
对 Foo -> Bar
的签名?
function type annotation docs写的很详细。看起来以下内容应该适合您
/* @flow */
type Bar = number;
type Foo = {
bar: Bar,
};
const prop = y => x => x[y];
const fooToBar : Foo => Bar = prop('bar');
No errors!
鉴于这些类型:
type Bar = number;
type Foo = {
bar: Bar,
};
还有这个无积分转换函数fooToBar
:
import { prop } from 'ramda';
const fooToBar = prop('bar');
是否可以注释 fooToBar
对 Foo -> Bar
的签名?
function type annotation docs写的很详细。看起来以下内容应该适合您
/* @flow */
type Bar = number;
type Foo = {
bar: Bar,
};
const prop = y => x => x[y];
const fooToBar : Foo => Bar = prop('bar');
No errors!