gpt4 book ai didi

flowtype - 为什么 Flow 需要标注导出函数的参数?

转载 作者:行者123 更新时间:2023-12-05 00:16:42 24 4
gpt4 key购买 nike

以下代码( Flow playground ):

/* @flow */

function a(p) {}
module.exports = a

抛出异常
3: function a(p) {}
^ parameter `p`. Missing annotation

这是为什么?我希望那种类型 any将自动假定参数 p .

最佳答案

来自 documentation :

Module Boundaries

Flow requires annotations at the boundaries of modules. This allows Flow to analyze modules in isolation which improves the performance of checking types across module boundaries. We’ve found that this helps to improve the self-documenting nature of module interfaces as well.

关于flowtype - 为什么 Flow 需要标注导出函数的参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41419511/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com