-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Description
Prior Issues
Not that I could find unfortunately.
I plan to submit a PR to fix this.
What is the current behavior?
Unexpected type error when exactOptionalPropertyTypes is enabled:
import { type Reducer, combineReducers } from 'redux';
type MyAction = { type: 'foo' };
type State = string;
declare const nested: Reducer<State, MyAction>;
type Combined = { nested: State };
// ❌ Error
// Type 'Reducer<{ nested: string; }, MyAction, Partial<{ nested: never; }>>' is not assignable to type 'Reducer<Combined, MyAction, Partial<Combined>>'.
// Type 'string' is not assignable to type 'never'.
const combined: Reducer<
Combined,
MyAction,
Partial<Combined>
> = combineReducers({ nested });This only happens when using a custom action type, i.e. changing MyAction to the Redux Action type makes the error disappear.
I believe we need to thread the custom action type through combineReducers to PreloadedStateShapeFromReducersMapObject so we can use it in the conditional type.
Steps to Reproduce
See above.
What is the expected behavior?
No type error.
Environment Details
N/A
Metadata
Metadata
Assignees
Labels
No labels