即使在范围内导入,也找不到名称'REHYDRATE'

时间:2017-10-06 04:16:57

标签: typescript redux

我有以下TypeScript 2.5代码:

import { REHYDRATE } from 'redux-persist/constants';

export interface Rehydrate {
    readonly type: REHYDRATE;
    readonly payload: AppState;
}

哪些错误:

ERROR in [at-loader] ./src/actions.ts:175:20
    TS2304: Cannot find name 'REHYDRATE'.

(第175行是readonly type: REHYDRATE;。)为什么? REHYDRATE显然属于范围。

1 个答案:

答案 0 :(得分:1)

  

(第175行是只读类型:REHYDRATE;一个。)为什么? REHYDRATE显然属于范围。

它作为变量导入,而不是Type

修复

import { REHYDRATE } from 'redux-persist/constants';

export interface Rehydrate {
    readonly type: typeof REHYDRATE;
    readonly payload: AppState;
}

更多

概念:https://basarat.gitbooks.io/typescript/docs/project/declarationspaces.html