flow-typed 安装
全局
npm install -g flow-typed
测试代码
- 一个简单全局函数
目录根目录 flow-typed
userLibDef.js
declare function userlogin(a: number): string;
- 配置flowconfig 查找typedefine
[ignore]
[include]
[libs]
./flow-typed
[lints]
[options]
[strict]
- 代码使用
// @flow
function userlogin(index) {
return "dalongdemo"
}
const shortid = require("shortid");
function shortid_gen():string{
return shortid.generate()
}
function getinfo(name:string):string {
return name;
}
module.exports={
name:"dalong-appdemo",
age:33,
get:getinfo,
id:shortid_gen(),
login: userlogin(44)
}
参考资料
https://flow.org/en/docs/config/
https://flow.org/en/docs/libdefs/creation/
原文地址:https://www.cnblogs.com/rongfengliang/p/9380680.html
时间: 2024-10-17 09:54:58