Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type '{ ... }' does not satisfy the constraint 'AsyncThunkConfig' #4664

Closed
jonathan-rosa opened this issue Oct 15, 2024 · 1 comment
Closed

Comments

@jonathan-rosa
Copy link

Possibly related to #3758

Using @reduxjs/toolkit in my TypeScript project leads to these type errors related to AsyncThunkConfig.

Initially tsc was latest version, so I downgraded to 5.5.4 as it is defined in package.json and it does not help. How am I supposed to be using TypeScript with redux-toolkit?

node_modules/@reduxjs/toolkit/dist/index.d.ts:1445:148 - error TS2344: Type '{ [K in keyof (ThunkApiConfig & Omit<CurriedThunkApiConfig, keyof ThunkApiConfig>)]: (ThunkApiConfig & Omit<...>)[K]; }' does not satisfy the constraint 'AsyncThunkConfig'.
  Types of property 'dispatch' are incompatible.
    Type 'ThunkApiConfig["dispatch"] & CurriedThunkApiConfig["dispatch"]' is not assignable to type 'ThunkDispatch<unknown, unknown, UnknownAction>'.

1445     <Returned, ThunkArg, ThunkApiConfig extends AsyncThunkConfig>(typePrefix: string, payloadCreator: AsyncThunkPayloadCreator<Returned, ThunkArg, OverrideThunkApiConfigs<CurriedThunkApiConfig, ThunkApiConfig>>, options?: AsyncThunkOptions<ThunkArg, OverrideThunkApiConfigs<CurriedThunkApiConfig, ThunkApiConfig>>): AsyncThunk<Returned, ThunkArg, OverrideThunkApiConfigs<CurriedThunkApiConfig, ThunkApiConfig>>;
                                                                                                                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@reduxjs/toolkit/dist/index.d.ts:1445:251 - error TS2344: Type '{ [K in keyof (ThunkApiConfig & Omit<CurriedThunkApiConfig, keyof ThunkApiConfig>)]: (ThunkApiConfig & Omit<...>)[K]; }' does not satisfy the constraint 'AsyncThunkConfig'.

1445     <Returned, ThunkArg, ThunkApiConfig extends AsyncThunkConfig>(typePrefix: string, payloadCreator: AsyncThunkPayloadCreator<Returned, ThunkArg, OverrideThunkApiConfigs<CurriedThunkApiConfig, ThunkApiConfig>>, options?: AsyncThunkOptions<ThunkArg, OverrideThunkApiConfigs<CurriedThunkApiConfig, ThunkApiConfig>>): AsyncThunk<Returned, ThunkArg, OverrideThunkApiConfigs<CurriedThunkApiConfig, ThunkApiConfig>>;
                                                                                                                                                                                                                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@reduxjs/toolkit/dist/index.d.ts:1445:348 - error TS2344: Type '{ [K in keyof (ThunkApiConfig & Omit<CurriedThunkApiConfig, keyof ThunkApiConfig>)]: (ThunkApiConfig & Omit<...>)[K]; }' does not satisfy the constraint 'AsyncThunkConfig'.

1445     <Returned, ThunkArg, ThunkApiConfig extends AsyncThunkConfig>(typePrefix: string, payloadCreator: AsyncThunkPayloadCreator<Returned, ThunkArg, OverrideThunkApiConfigs<CurriedThunkApiConfig, ThunkApiConfig>>, options?: AsyncThunkOptions<ThunkArg, OverrideThunkApiConfigs<CurriedThunkApiConfig, ThunkApiConfig>>): AsyncThunk<Returned, ThunkArg, OverrideThunkApiConfigs<CurriedThunkApiConfig, ThunkApiConfig>>;
                                                                                                                                                                                                                                                                                                                                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@reduxjs/toolkit/dist/index.d.ts:1446:76 - error TS2344: Type '{ [K in keyof (ThunkApiConfig & Omit<CurriedThunkApiConfig, keyof ThunkApiConfig>)]: (ThunkApiConfig & Omit<...>)[K]; }' does not satisfy the constraint 'AsyncThunkConfig'.
  Types of property 'dispatch' are incompatible.
    Type 'ThunkApiConfig["dispatch"] & CurriedThunkApiConfig["dispatch"]' is not assignable to type 'ThunkDispatch<unknown, unknown, UnknownAction>'.

1446     withTypes<ThunkApiConfig extends AsyncThunkConfig>(): CreateAsyncThunk<OverrideThunkApiConfigs<CurriedThunkApiConfig, ThunkApiConfig>>;
                                                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@reduxjs/toolkit/dist/index.d.ts:1677:101 - error TS2344: Type '{ [K in keyof (ThunkApiConfig & Omit<CurriedThunkApiConfig, keyof ThunkApiConfig>)]: (ThunkApiConfig & Omit<...>)[K]; }' does not satisfy the constraint 'PreventCircular<AsyncThunkConfig>'.
  Types of property 'state' are incompatible.
    Type 'ThunkApiConfig["state"] & CurriedThunkApiConfig["state"]' is not assignable to type 'never'.

1677     withTypes<ThunkApiConfig extends PreventCircular<AsyncThunkConfig>>(): AsyncThunkCreator<State, OverrideThunkApiConfigs<CurriedThunkApiConfig, ThunkApiConfig>>;
                                                                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@reduxjs/toolkit/dist/index.d.ts:2054:15 - error TS2420: Class 'TaskAbortError' incorrectly implements interface 'SerializedError'.
  Types of property 'code' are incompatible.
    Type 'string | undefined' is not assignable to type 'string'.
      Type 'undefined' is not assignable to type 'string'.

2054 declare class TaskAbortError implements SerializedError {
                   ~~~~~~~~~~~~~~


Found 6 errors in the same file, starting at: node_modules/@reduxjs/toolkit/dist/index.d.ts:1445
@EskiMojo14
Copy link
Collaborator

your type checker shouldn't be checking our type definitions - turn skipLibCheck on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants