我在项目中视图使用如下语法来定义一个数据接口:
interface IUserInfo extends Immutable.Map<string, any> {
}
但是报错:Cannot find namespace 'Immutable'
,我已经下载了@types/redux-immutable
。
我已经知道有一种方式是在xxx.d.ts
文件里定义这个类型,然后在tsconfig.json
里配置typeRoot
,出了这种方式,还有其他方式能让Immutable这个类型全局可用吗?
Immutable
是属于immutable
这个包里的, 和 redux-immutable 没关系, redux-immutable 只是简单的把 redux 和 immutable 桥接起来, 你有装immutable
吗,immutable
自己有带 type 定义, 不需要在装额外的@types/immutable
.另外你是要
extends Immutable.map
,Immutable.Map
是一个类, 而不能当做一个类型命名空间来用, 你要导入Immutable
才行.