Skip to content

Type 'CaseReducerWithPrepare' constrains its generic #688

Closed
Bhanditz/redux-starter-kit
#1
@8times12

Description

@8times12

On typings.d.ts file of @redux/toolkit, a generic Action of type CaseReducerWithPrepare extends type PayloadAction with default generics and constrains its method prepare to return void. However, a method prepare of a payload action seems able to return any. Does this type declaration fit the entity of the API?

PayloadAction:

export declare type PayloadAction<P = void, T extends string = string, M = never, E = never> = {
    payload: P;
    type: T;
} & ([M] extends [never] ? {} : {
    meta: M;
}) & ([E] extends [never] ? {} : {
    error: E;
});

CaseReducerWithPrepare:

export declare type CaseReducerWithPrepare<State, Action extends PayloadAction> = {
    reducer: CaseReducer<State, Action>;
    prepare: PrepareAction<Action['payload']>;
};

It looks like <any> is required after Action extends PayloadAction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions