首页 > 其他 > 详细

flow flow-typed 定义简单demo

时间:2018-07-28 10:16:03      阅读:277      评论:0      收藏:0      [点我收藏+]

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/

flow flow-typed 定义简单demo

原文:https://www.cnblogs.com/rongfengliang/p/9380680.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!