flowtype:将函数的返回类型更改为void

问题描述:

我需要将函数的返回类型更改为void。flowtype:将函数的返回类型更改为void

例如:

import { func_one } from './examples'; 

// FuncOneType is a function type with the same signature 
// as func_one. 
type FuncOneType = typeof func_one; 

// FuncOneTypeWithoutReturn is similar to FuncOneType but 
// the return type is void. This works. 
const func_one_void = (...args) => {func_one(...args)}; 
type FuncOneTypeVoidReturn = typeof func_one_void; 

// I need something like to avoid the intermediate 
// function func_one_void. How can I achieve this? 
type FuncOneTypeVoidReturn = $Arguments<func_one> => void; 

我们聊起这在GitHub的问题了一点,但想在这里把答案,以防万一有人在土地通过谷歌这个问题。当前流无法表示“函数的所有参数的类型”或键入一个接受另一个函数并保留其参数类型但返回不同类型的高阶函数。

(另请注意,func_one_void以上示例并没有真正的工作,你会喜欢的。该参数是函数不再有任何类型的,但不是仅仅any