[Flow] Declare types for application
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; ....
[Flow] Declare types for application的更多相关文章
- 3.3 Execution Flow of a DDD Based Application 基于DDD的应用程序执行流程
3.3 Execution Flow of a DDD Based Application 基于DDD的应用程序执行流程 The figure below shows a typical reques ...
- [Windows Azure] Adding Sign-On to Your Web Application Using Windows Azure AD
Adding Sign-On to Your Web Application Using Windows Azure AD 14 out of 19 rated this helpful - Rate ...
- Intel® Threading Building Blocks (Intel® TBB) Developer Guide 中文 Parallelizing Data Flow and Dependence Graphs并行化data flow和依赖图
https://www.threadingbuildingblocks.org/docs/help/index.htm Parallelizing Data Flow and Dependency G ...
- Reading SBAR SDN flow-Based monitoring and Application Recognition
概要 在sdn下,控制平面基于网络测量的的数据控制网络,而细粒度的管理得益于细粒度的测量数据.针对sdn环境下的细粒度测量(识别具体应用程序),可以实现对细粒度的流量管控. 设计了识别系统SBAR,对 ...
- Spring Web Flow 的优缺点
# 前言 Spring Web Flow = SWF 最近学习了<Spring实战>的第八章,Spring Web Flow.感觉是个不错的东西.无奈发现网上的资料少之又少.后来发现根本没 ...
- Nginx+lua+openresty精简系列
1. CentOS系统安装openresty 你可以在你的 CentOS 系统中添加 openresty 仓库,这样就可以便于未来安装或更新我们的软件包(通过 yum update 命令).运行下面的 ...
- nginx配置文件nginx.conf超详细讲解
#nginx进程,一般设置为和cpu核数一样worker_processes 4; #错误日志存放目录 error_log /data1/logs/er ...
- Windows下apache php wordpress配置
2. Use notepad to open httpd.conf config file. Make use the line "LoadModule rewrite_module mod ...
- Chapter 6 — Improving ASP.NET Performance
https://msdn.microsoft.com/en-us/library/ff647787.aspx Retired Content This content is outdated and ...
随机推荐
- Light OJ 1373 Strongly Connected Chemicals 二分匹配最大独立集
m种阳离子 n种阴离子 然后一个m*n的矩阵 第i行第j列为1代表第i种阴离子和第j种阴离子相互吸引 0表示排斥 求在阳离子和阴离子都至少有一种的情况下 最多存在多少种离子能够共存 阴阳离子都至少须要 ...
- Python 极简教程(十二)逻辑控制语句 if else
计算机软件之所以能够对不同的情况进行不同的处理,就是我们在编码的时候,通过逻辑控制语句,告诉软件在不同的情况下应该做什么处理. 比如我们在登录的时候,那么当你输入正确的账号密码和错误的账号密码,完全是 ...
- [D3] Build an Area Chart with D3 v4
Similar to line charts, area charts are great for displaying temporal data. Whether you’re displayin ...
- 算法中的优化问题(optimization problem)
和多数算法不同的是,有些问题的答案不只一个,而是需要在多个答案中,按照一定标准选出"最佳"答案,这类问题就统称为"优化问题"(optimization prob ...
- Kinect开发笔记之三Kinect开发环境配置具体解释
0.前言: 首先说一下我的开发环境,Visual Studio是2013的,系统是win8的64位版本号,SDK是Kinect for windows SDK 1.8版本 ...
- html5 10大html5前端框架
Bootstrap 首先说 Bootstrap,估计你也猜到会先说或者一定会有这个( 呵呵了 ),这是说明它的强大之处,拥有框架一壁江山的势气.自己刚入道的时候本着代码任何一个字母都得自己敲出来挡我者 ...
- iOS_01_什么是ios
* ios是一款由苹果公司开发的操作系统(os是Operating Systen的简称),就像平时在电脑上用的Window XP.Window 7.都是操作系统. * 那什么是操作系统呢?操作系统其实 ...
- swift项目第二天:初始化项目
初始化项目 项目的部署版本 之后项目会运行在哪些系统中 横竖屏的支持 iPhone应用一般只支持横屏 iPhone游戏一般支持竖屏 iPad横竖屏都支持 设置项目的图标和启动图片 项目的图标(美工做好 ...
- POJ 2785 4 Values whose Sum is 0 Hash!
http://poj.org/problem?id=2785 题目大意: 给你四个数组a,b,c,d求满足a+b+c+d=0的个数 其中a,b,c,d可能高达2^28 思路: 嗯,没错,和上次的 HD ...
- 选择标识符(identifier)
整数通常是标识列最好的选择,因为它们很快并且可以使用auto_increment:千万不要使用enum和set类型作为标识列:尽量避免使用字符串类型作为标识列,因为他们很消耗空间,并且通常比数字类型慢 ...