Skip to content

[RTK Query] [TS] Exported variable using 'StaggerOptions' from external module cannot be namedΒ #1722

@benweier

Description

@benweier

I'm using the "bailing out of error re-tries" example at https://redux-toolkit.js.org/rtk-query/usage/customizing-queries#bailing-out-of-error-re-tries with TypeScript and getting a message:

Exported variable 'staggeredBaseQueryWithBailOut' has or is using name 'StaggerOptions' from external module "[..]/@reduxjs/toolkit/dist/query/retry" but cannot be named.

Looking into the retry.d.ts definition and StaggerOptions is not exported, while temporarily adding export interface StaggerOptions resolves the message. I've made a workaround by redeclaring the module like

import { BaseQueryEnhancer } from '@reduxjs/toolkit/query/react'

declare module '@reduxjs/toolkit/query/react' {
  export interface StaggerOptions {
    maxRetries?: number
    backoff?: (attempt: number, maxRetries: number) => Promise<void>
  }

  function fail(e: any): never

  const retry: BaseQueryEnhancer<unknown, StaggerOptions, void | StaggerOptions> & {
    fail: typeof fail
  }
}

but it would be nice to have StaggerOptions exported so that it can be found by TS

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