Skip to content

transformResponse typings doesn't match arguments #1790

@LoiKos

Description

@LoiKos

Hi,

Using RTK Query and defining an api through api.injectEndpoints i tried to transformResponse on query but i have a trouble with the third arguments typings.

const localizationApi = api.injectEndpoints({
 searchLocations: builder.query<
      Place[] | Country[] | (Place|Country)[],
      { searchTerms: string; type?: LocationType; placeType?: PlaceType }
    >({
      query: ({ searchTerms }) => ({
        url: ...,
        params: { input: searchTerms },
      }),
      transformResponse: (response: Place[] | Country[] | (Place|Country)[], meta, arg) => {
        console.log(arg)
        // trouble here with arg 
        return response as Place[] | Country[] | (Place|Country)[]
      },
    }),})

So when i look at the console.log(arg) i can see this object :

Capture d’écran 2021-12-01 à 16 56 45

but in editor (vscode) i see arg typed as follow :

Capture d’écran 2021-12-01 à 17 10 29

There should be a missing type around the args provide by user.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions