小编gf3*_*gf3的帖子

是否可以将流类型包装在不可变容器中?

例如,给出以下记录:

type UserRecord = {
  id: string;
  name: ?string;
  age: number;
}
Run Code Online (Sandbox Code Playgroud)

有没有办法做相同的以下内容:

/* @flow */

import { List, Map } from 'immutable'

const users: List<Map<UserRecord>> = List();    
let user: Map<UserRecord>;

user = Map({ id: '666', age: 30 });
users.push(user);
Run Code Online (Sandbox Code Playgroud)

否则我最终会简单地使用类似于Map<string, any>我认为将Immutable.js与Flow类型系统一起使用的东西.

javascript flowtype immutable.js

14
推荐指数
1
解决办法
1164
查看次数

标签 统计

flowtype ×1

immutable.js ×1

javascript ×1