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. Leetcode:populating_next_right_pointers_in_each_node题解

    一.     题目 对于结构体:struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } ...

  2. 81.内存模式实现cgi查询

    创建全局的二级指针 char ** g_pp;//全局的二级指针 获取数据有多少行 //获取行数 int getimax() { ; FILE *pf = fopen(path, "r&qu ...

  3. 学习笔记(二):javascript之dom操作

    一.document.getElementById()    根据Id获取元素节点 <div id="div1"> <p id="p1"> ...

  4. GitHub上常用命令(工作中几乎每天用到的命令)

    查看自己当前分支 git branch 查看远程和本地分支 git branch -a 查看origin下的分支 git config -vv git config --lis 创建分支 git br ...

  5. Qt学习 之 Socket通信

    近期写大作业用到Qt的Socket部分.网上关于这部分的资料都太过复杂,如今总结一下一些简单的应用.有机会能够给大家讲讲用Socket传送文件的代码. 这里主要解说怎样实现TCP和UDP的简单通信. ...

  6. [RxJS] Avoid mulit post requests by using shareReplay()

    With the shareReplay operator in place, we would no longer fall into the situation where we have acc ...

  7. amazeui学习笔记--css(HTML元素2)--代码Code

    amazeui学习笔记--css(HTML元素2)--代码Code 一.总结 1.行内代码:code标签<code> 2.代码片段:pre标签<pre> 3.限制代码块高度:添 ...

  8. 分治法(divide & conquer)与动态规划(dynamic programming)应用举例

    动态规划三大重要概念:最优子结构,边界,状态转移公式(问题规模降低,如问题由 n 的规模降低为 n−1 或 n−2 及二者之间的关系): 0. 爬台阶 F(n)⇒F(n−1)+F(n−2) F(n−1 ...

  9. Redo current损坏

       如果损坏的是current redo log (select group#,sequence#,archived,status from v$log;) 有两种情况: A.   数据库是正常关闭 ...

  10. 汉字的ascii