Do you want to request a feature or report a bug?
Bug.
What is the current behavior?
When I start compilation I always gets a stack error. Which says that my initialState is broken or someone else. Moreover, my app is compile normally if I just cut off initialState prop, but it's not a good solutions. It's work normally on .js file version of the app. Seem like redux have some problems with the TypeScript.
TS2345: Argument of type '{ titleSwitch: string; }' is not assignable to parameter of type 'DeepPartial<any>'.
Property 'titleSwitch' is incompatible with index signature.
Type 'string' is not assignable to type 'DeepPartial<any>'.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar.
import { Store, createStore } from 'redux'
import reducer from './reducers'
const initialState = {
titleSwitch: false
}
const store = (): Store<any> => {
return createStore(
reducer,
initialState
)
}
What is the expected behavior?
Should work without any errors.
Which versions of Redux, and which browser and OS are affected by this issue? Did this work in previous versions of Redux?
"redux": "^4.0.0",
"typescript": "^3.1.1",
"webpack": "^4.16.5"
This is a bug tracker, not a support system. For usage questions, please use Stack Overflow or Reactiflux where there are a lot more people ready to help you out - you'll probably get a better answer faster. Thanks!
@markerikson hi, why do you think this is not a bug?
@BiosBoy I got the same error, you probably find the answer already. I change
combineReducers(...)
for
combineReducers<IRootState>(...)
and type my initialState.
I got same error
Argument of type 'AppState' is not assignable to parameter of type 'DeepPartial<{ todos: { id: any; text: any; completed: boolean; }[]; }>'.
Most helpful comment
@BiosBoy I got the same error, you probably find the answer already. I change
combineReducers(...)for
combineReducers<IRootState>(...)and type my initialState.