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的更多相关文章

  1. 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 ...

  2. [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 ...

  3. 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 ...

  4. Reading SBAR SDN flow-Based monitoring and Application Recognition

    概要 在sdn下,控制平面基于网络测量的的数据控制网络,而细粒度的管理得益于细粒度的测量数据.针对sdn环境下的细粒度测量(识别具体应用程序),可以实现对细粒度的流量管控. 设计了识别系统SBAR,对 ...

  5. Spring Web Flow 的优缺点

    # 前言 Spring Web Flow = SWF 最近学习了<Spring实战>的第八章,Spring Web Flow.感觉是个不错的东西.无奈发现网上的资料少之又少.后来发现根本没 ...

  6. Nginx+lua+openresty精简系列

    1. CentOS系统安装openresty 你可以在你的 CentOS 系统中添加 openresty 仓库,这样就可以便于未来安装或更新我们的软件包(通过 yum update 命令).运行下面的 ...

  7. nginx配置文件nginx.conf超详细讲解

    #nginx进程,一般设置为和cpu核数一样worker_processes 4;                        #错误日志存放目录 error_log  /data1/logs/er ...

  8. Windows下apache php wordpress配置

    2. Use notepad to open httpd.conf config file. Make use the line "LoadModule rewrite_module mod ...

  9. Chapter 6 — Improving ASP.NET Performance

    https://msdn.microsoft.com/en-us/library/ff647787.aspx Retired Content This content is outdated and ...

随机推荐

  1. ubuntu-系统密匙

    1.安装虚拟机xp,需要密匙,网上搜了一个,验证能用 MRX3F-47B9T-2487J-KWKMF-RPWBY 2.安装vm也需要密匙,如下可用 HC6JC-FPJ4M-RZM61-48852-2A ...

  2. openGLES(一)

    准备工作 工具安装 jdk安装 sdk安装 IDE开发环境 一个手机 推荐使用真机,它可以反映真实的性能和结果. 虚拟机创建 Android SDK 执行SDK Manager.exe Tools-- ...

  3. vue 星星评分组件

    显示评分和打分组件,可现实半颗星星效果 效果图: 参数名 类型 说明 score Number 分数 ,默认0,保留一位小数 disabled Boolean 是否只读,默认false,鼠标点击可以打 ...

  4. nuxt.js配置BASE_URL(基本域名)和NODE_ENV(环境变量)

    一直以来,开发环境和生产环境的数据接口域名不一样总是困扰着我 每次打测试包或者线上包,我都得手动切换域名,我相信很多人的做法跟这差不多,类似下面这样: (你已经注意到,这个文件已经被我无情的删除了,因 ...

  5. selenium 自动化基础知识(各种定位)

    元素的定位 webdriver 提供了一很多对象定位方法  例如: [ id ] , name , class name , link text , partial link text , tag n ...

  6. jmeter--函数助手对话框之参数详解

    详解JMeter函数和变量 测试人员可以在JMeter的选项菜单中找到函数助手对话框("Function Helper"对话框),如图11-1所示. 图11-1 函数助手(Func ...

  7. JS数据结构第二篇---链表

    一.什么是链表 链表是一种链式存储的线性表,是由一组节点组成的集合,每一个节点都存储了下一个节点的地址:指向另一个节点的引用叫链:和数组中的元素内存地址是连续的相比,链表中的所有元素的内存地址不一定是 ...

  8. minizlib

    ZLIB开源库采用的是DEFLATE压缩算法,已经不支持加密功能,实际上功能还存在于代码中,采用MINIZIP可以支持对ZIP文件的加解密. ZLIB目前最新的是1.2.7,MINIZIP最新的版本是 ...

  9. 【Codeforces Round #185 (Div. 2) D】Cats Transport

    [链接] 链接 [题意] 有n座山,m只猫. 每只猫都在其中的一些山上玩. 第i只猫在h[i]山上玩,且会在t[i]时刻出现在山脚下(然后就一直在那里等) 然后有p个人. 它们听从你的安排. 在某个时 ...

  10. DOS命令具体解释

    net use $">\\ip\ipc$Content$nbsp;" " /user:" " 建立IPC空链接   net use $" ...