[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 ...
随机推荐
- 几种基于Java的SQL解析工具的比较与调用
1.sqlparser http://www.sqlparser.com/ 优点:支持的数据库最多,除了传统数据库外还支持hive和greenplum一类比较新的数据库,调用比较方便,功能不错 缺点: ...
- 26.SpringBoot事务注解详解
转自:https://www.cnblogs.com/kesimin/p/9546225.html @Transactional spring 事务注解 1.简单开启事务管理 @EnableTrans ...
- Vue 使用use、prototype自定义自己的全局组件
使用Vue.use()写一个自己的全局组件. 目录如下: 然后在Loading.vue里面定义自己的组件模板 <template> <div v-if="loadFlag& ...
- ClickOnce
Clic WPF ClickOnce应用程序IIS部署发布攻略 WPF程序非常适合公司内网使用,唯一缺点就是客户端要安装.net框架4.0.优势也很明显,在客户端运行的是一个WinForm程序,自 ...
- 洛谷—— P1967 货车运输 || COGS——C 1439. [NOIP2013]货车运输
https://www.luogu.org/problem/show?pid=1967#sub || http://www.cogs.pro/cogs/problem/problem.php?pi ...
- 下次自己主动登录(记住password)功能
1:进入cookie插件 <script src="jquery.cookie.js" type="text/javascript"></sc ...
- 1.4 Python基础知识 - 代码书写格式及条件判断"if ... else ..."
一.代码的书写规则 在所有的开发语言中,代码之间都是有关联的关系,有的是包含关系,有的是上下级关系,有的是代表语句的结束.在python中也是有相应的规则的: 1.在没有上下级关系的代码中,代码要顶行 ...
- 用static 创建类的单例
1.0 说明 通过函数调用new的static 类对象,由于static 对象只能初始化一次,由此构成单例运行. 2.0 直接代码 代码为windows,win32工程,因为只有一个文件,不上传工程 ...
- 飞镖忍者 quick-cocos2d-x3.2
经典的入门小游戏.这里用quick-cocos2d-x3.2又一次写一遍,以便熟悉下quick 首先,创建project,假设不会自行百度啊. 1.编译效果例如以下: watermark/2/text ...
- Android android.database.CursorIndexOutOfBoundsException:Index -1 requested, with a size of 1
Android中数据库处理使用cursor时,游标不是放在为0的下标,而是放在为-1的下标处开始的. 也就是说返回给cursor查询结果时,不能够马上从cursor中提取值. 下面的代码会返回错误 U ...