简体   繁体   English

可以流动注释无点函数吗?

[英]Possible to flow-annotate a point-free function?

Given these types: 鉴于以下类型:

type Bar = number;
type Foo = {
  bar: Bar,
};

And this point-free conversion function fooToBar : 而这个无点转换函数fooToBar

import { prop } from 'ramda';
const fooToBar = prop('bar');

Is it possible to annotate fooToBar 's signature of Foo -> Bar ? 是否可以注释fooToBarFoo -> Bar签名Foo -> Bar

The function type annotation docs are pretty detailed. 函数类型注释文档非常详细。 It looks like the following should work for you 看起来以下内容适合您

/* @flow */

type Bar = number;
type Foo = {
  bar: Bar,
};

const prop = y => x => x[y];

const fooToBar : Foo => Bar = prop('bar');

Flow says Flow说

No errors!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM