import { createStore } from "redux";
import * as storage from "redux-storage";
const reducer = storage.reducer((state, action) => ({}));
const store = createStore(reducer, {});
使用strict
启用了打字稿的上述代码时,我收到以下警告:
[ts] Argument of type 'Reducer<{}>' is not assignable to parameter of type 'Reducer<{}, AnyAction>'.
Types of parameters 'state' and 'state' are incompatible.
Type '{} | undefined' is not assignable to type '{}'.
Type 'undefined' is not assignable to type '{}'.
我了解 TS 严格模式是什么,但我不明白为什么它将我的状态解释为可能undefined
我可能做错了什么?或者我怎么能在不做一些懒惰的事情的情况下处理错误as any
?