Reducer TypeScript definitition for combineReducers
Opened this issue · 2 comments
jeroenlandheer commented
I'm having some issues here to get the i18SnState
reducer to get into my combineReducers()
function. TypeScript complains that the type is not compatible with Reducer<IreduxI18nState>
because of the state parameter not accepting undefined
in the definition.
My workaround is this line of code:
export const reducer: Reducer<IreduxI18nState> = (state: IreduxI18nState | undefined, incomingAction: Action): IreduxI18nState => i18nState(state, incomingAction);
I think (not 100% sure) this can be solved by changing the signature of the this line in index.d.ts
:
export function i18nState(state: IreduxI18nState, action: Action): IreduxI18nState
to
export function i18nState(state: IreduxI18nState | undefined, action: Action): IreduxI18nState
wijnbladh commented
Additionally, it would seem that this:
export interface IGetTranslateFunctionResponse {
(textKey: string, params?: string[], comment?: string): string;
}
should be like this, or something:
export interface IGetTranslateFunctionResponse {
(textKey: string, params?: { [key: string]: string }, comment?: string): string;
}
(based on looking at the source code)
JosephBrooksbank commented
Any updates on this? index.d.ts
still appears to be incorrect, at least with regards to IGetTranslateFunctionResponse
.