In Flow, you can make global declarion about types.

Run:

flow init

It will generate .flowconfig file, open it and add few lines of configration.

[libs]
decls/ [ignore]
.*/node_modules/.*

So it says that go to find 'decls' folders and use what has been defined as global type checking.

Declear a variable:

declare type PetAction = 'adopt' | 'foster';

Declear a function:

declare type PetShelterDispatch = (x: PetShelterActions) => void;

Declear an interface:

declare type Pet = {
name: string;
id: number;
from: string;
type: PetType;
locationId: number;
action?: PetAction;
};

All those will be global available for React components.

So you can use those, for example:

// @flow
module.exports = ([
{
type: 'dog',
name: 'Snoopy',
from: 'Charlie',
locationId: ,
id:
},
{
type: 'cat',
name: 'Garfield',
from: 'John',
locationId: ,
id:
}
]: Array<Pet>);

It is also good to declear type for "state", 'props':

// @flow

const React = require('react');

type ModalProps = {
dispatch: PetShelterDispatch;
pet: Pet;
};
type ModalState = {
inquiry: ?PetInquiry;
}; class PetModal extends React.Component { props: ModalProps;
state: ModalState;
onSubmitClick: () => void; ....

最新文章

  1. spring-boot-framework 如何自动将对象返回成json格式
  2. android自定义viewgroup实现等分格子布局
  3. Spring的IoC容器注入的类型
  4. HDU 1425 sort 【哈希入门】
  5. Expat Parser解析xml文件
  6. 17、SQL Server 备份和还原
  7. Nmap功能与常用命令
  8. 入门VMware Workstation下的Debian学习之Vim简单使用(三)
  9. Qt 开发 MS VC 控件终极篇
  10. C语言程序设计(基础)- 第14、15周作业
  11. PHP中的反射模拟框架中控制器的调度
  12. JVM源码分析之SystemGC完全解读
  13. Mac 远程桌面 ubuntu16.04 unity
  14. ORM模型
  15. Steering Behaviors
  16. 【转】Java学习---内存泄露与溢出的区别
  17. Linq的简介和基础知识学习
  18. Idea多个module下maven的pom.xml失效的问题
  19. select2 选择框插件
  20. [one day one question] 有没有免费接收短信验证用于注册的软件或者平台?

热门文章

  1. Spring MVC框架实例
  2. JQuery 当点击input后,单选多选的选中状态
  3. solr6.3+tomcat8报错HTTP Status 403 – Forbidden解决办法
  4. JIRA6.3.6 安装汉化破解指南
  5. 支付宝支付返回通知时 notify_url和return_url的选择
  6. window.print()打印网页(一)
  7. LA 3135 - Argus
  8. C#实现自己主动升级(附源代码)
  9. php 面试题一(看视频的学习量比网上瞎转悠要清晰和明了很多)(看视频做好笔记)(注重复习)
  10. TEMPDB