将 React Native Debugger 与 typescript 结合使用
Usage of React Native Debugger with typescript
要设置 React Native 调试器,我们必须像这样声明一个 composer:
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
const store = createStore(
rootReducers,
composeEnhancers(applyMiddleware(thunk))
)
但是当与 typescript 一起使用时,TS 编译器说:Cannot find name 'window'.ts(2304)
已经尝试将 tsconfig.json
中的密钥 lib
更改为:
"lib": ["es6", "DOM"]
但错误变为:
Property '__REDUX_DEVTOOLS_EXTENSION_COMPOSE__' does not exist on type 'Window & typeof globalThis'.ts(2339)
实际上,React Native Debugger 不需要设置。只需使用 Redux
和 React Native Debugger 即可捕获您的状态。
使用__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
需要写window. __REDUX_DEVTOOLS_EXTENSION_COMPOSE__
而window
对象只是为了浏览器。
要设置 React Native 调试器,我们必须像这样声明一个 composer:
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
const store = createStore(
rootReducers,
composeEnhancers(applyMiddleware(thunk))
)
但是当与 typescript 一起使用时,TS 编译器说:Cannot find name 'window'.ts(2304)
已经尝试将 tsconfig.json
中的密钥 lib
更改为:
"lib": ["es6", "DOM"]
但错误变为:
Property '__REDUX_DEVTOOLS_EXTENSION_COMPOSE__' does not exist on type 'Window & typeof globalThis'.ts(2339)
实际上,React Native Debugger 不需要设置。只需使用 Redux
和 React Native Debugger 即可捕获您的状态。
使用__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
需要写window. __REDUX_DEVTOOLS_EXTENSION_COMPOSE__
而window
对象只是为了浏览器。