我有以下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
显然属于范围。
答案 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