[Flow] Declare types for application
for application types Flow Declare
2023-09-14 09:00:52 时间
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: 0, id: 0 }, { type: 'cat', name: 'Garfield', from: 'John', locationId: 0, id: 1 } ]: 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; ....
相关文章
- git 错误: Unable to find remote helper for 'https'
- [PWA] Storage information for PWA application
- [React] Configure a React & Redux Application For Production Deployment and Deploy to Now
- [Angular 2] Using ngrx/store and Reducers for Angular 2 Application State
- Docker for windows 或者 docker-ce 加速下载镜像配置
- navicat for mysql只导出数据表结构
- [Spring Boot] Set Context path for application in application.properties
- [Python] Create a Log for your Python application
- [React] Configure a React & Redux Application For Production Deployment and Deploy to Now
- [Angular 2] Using ngrx/store and Reducers for Angular 2 Application State
- 未能正确加载“VSTS for Database Professionals Sql Server Data-tier Application”包。
- SAP Cloud SDK for JavaScript 概述
- /IWBEP/CX_MGW_TECH_EXCEPTION - expand issue for old service on Docu history node
- resource handler working logic for Fiori BSP application - how is javascript file loaded from BSP re
- SAP Cloud for Customer Cloud(C4C)Application Studio里的代码调试
- 关于SAP Cloud for Customer Cloud Application Studio登录失败的问题
- SAP Cloud for Customer Cloud Application Studio implementation manager
- 【Educational Codeforces Round 97 (Rated for Div. 2) C】Chef Monocarp
- 【目标检测】36、OTA: Optimal Transport Assignment for Object Detection
- 解读华为云GaussDB(for Influx):最佳实践之数据建模
- [BEROR]CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 8.1'
- 论文解读(S^3-CL)《Structural and Semantic Contrastive Learning for Self-supervised Node Representation Learning》
- Vimium C插件for Chrome(一百五十七)
- 转:Top 10 Strategic Technology Trends for 2019
- color picker for little vGL
- SpringBoot无法访问接口,报错:This application has no explicit mapping for /error, so you are seeing this as a fallback.
- e611. Setting Focus Traversal Keys for the Entire Application