Skip to content

Investigate TS 7.0 ( tsgo ) type issues #5156

@markerikson

Description

@markerikson

Tried adding a new typecheck job with tsgo, and got these errors:

Version 7.0.0-dev.20251207.1
Error: src/query/react/buildHooks.ts(1823,13): error TS2769: No overload matches this call.
  The last overload gave the following error.
    Argument of type '((currentState: ({ status: QueryStatus.uninitialized; originalArgs?: undefined; data?: undefined; error?: undefined; requestId?: undefined; endpointName?: string | undefined; startedTimeStamp?: undefined; fulfilledTimeStamp?: undefined; } & { ...; }) | ({ ...; } & { ...; }) | ({ ...; } & { ...; }) | ({ ...; } & { .....' is not assignable to parameter of type '(resultFuncArgs_0: ({ status: QueryStatus.uninitialized; originalArgs?: undefined; data?: undefined; error?: undefined; requestId?: undefined; endpointName?: string | undefined; startedTimeStamp?: undefined; fulfilledTimeStamp?: undefined; } & { ...; }) | ({ ...; } & { ...; }) | ({ ...; } & { ...; }) | ({ ...; } & {...'.
      Type '(currentState: ({ status: QueryStatus.uninitialized; originalArgs?: undefined; data?: undefined; error?: undefined; requestId?: undefined; endpointName?: string | undefined; startedTimeStamp?: undefined; fulfilledTimeStamp?: undefined; } & { ...; } & { ...; } & InfiniteQueryResultFlags) | ({ ...; } & ... 2 more ... ...' is not assignable to type '(resultFuncArgs_0: ({ status: QueryStatus.uninitialized; originalArgs?: undefined; data?: undefined; error?: undefined; requestId?: undefined; endpointName?: string | undefined; startedTimeStamp?: undefined; fulfilledTimeStamp?: undefined; } & { ...; }) | ({ ...; } & { ...; }) | ({ ...; } & { ...; }) | ({ ...; } & {...'.
        Types of parameters 'currentState' and 'resultFuncArgs' are incompatible.
          Type '({ status: QueryStatus.uninitialized; originalArgs?: undefined; data?: undefined; error?: undefined; requestId?: undefined; endpointName?: string | undefined; startedTimeStamp?: undefined; fulfilledTimeStamp?: undefined; } & { ...; }) | ({ ...; } & { ...; }) | ({ ...; } & { ...; }) | ({ ...; } & { ...; })' is not assignable to type '({ status: QueryStatus.uninitialized; originalArgs?: undefined; data?: undefined; error?: undefined; requestId?: undefined; endpointName?: string | undefined; startedTimeStamp?: undefined; fulfilledTimeStamp?: undefined; } & { ...; } & { ...; } & InfiniteQueryResultFlags) | ({ ...; } & ... 2 more ... & InfiniteQuery...'.
            Type '{ status: QueryStatus.uninitialized; originalArgs?: undefined; data?: undefined; error?: undefined; requestId?: undefined; endpointName?: string | undefined; startedTimeStamp?: undefined; fulfilledTimeStamp?: undefined; } & { ...; }' is not assignable to type '({ status: QueryStatus.uninitialized; originalArgs?: undefined; data?: undefined; error?: undefined; requestId?: undefined; endpointName?: string | undefined; startedTimeStamp?: undefined; fulfilledTimeStamp?: undefined; } & { ...; } & { ...; } & InfiniteQueryResultFlags) | ({ ...; } & ... 2 more ... & InfiniteQuery...'.
              Type '{ status: QueryStatus.uninitialized; originalArgs?: undefined; data?: undefined; error?: undefined; requestId?: undefined; endpointName?: string | undefined; startedTimeStamp?: undefined; fulfilledTimeStamp?: undefined; } & { ...; }' is not assignable to type '{ status: QueryStatus.uninitialized; originalArgs?: undefined; data?: undefined; error?: undefined; requestId?: undefined; endpointName?: string | undefined; startedTimeStamp?: undefined; fulfilledTimeStamp?: undefined; } & { ...; } & { ...; } & InfiniteQueryResultFlags'.
                Type '{ status: QueryStatus.uninitialized; originalArgs?: undefined; data?: undefined; error?: undefined; requestId?: undefined; endpointName?: string | undefined; startedTimeStamp?: undefined; fulfilledTimeStamp?: undefined; } & { ...; }' is missing the following properties from type 'InfiniteQueryResultFlags': hasNextPage, hasPreviousPage, isFetchingNextPage, isFetchingPreviousPage, and 2 more.
Error: src/tests/mapBuilders.test-d.ts(56,7): error TS2578: Unused '@ts-expect-error' directive.
Error: src/tests/mapBuilders.test-d.ts(58,9): error TS2769: No overload matches this call.
  The last overload gave the following error.
    Argument of type 'ActionCreatorWithPayload<number, "increment">' is not assignable to parameter of type 'string'.
Error: src/tests/mapBuilders.test-d.ts(67,7): error TS2578: Unused '@ts-expect-error' directive.
Error: src/tests/mapBuilders.test-d.ts(70,9): error TS2769: No overload matches this call.
  The last overload gave the following error.
    Argument of type '(state: number, action: { payload: number; type: "increment"; }) => number' is not assignable to parameter of type 'CaseReducer<number, Action<"decrement">>'.
      Types of parameters 'action' and 'action' are incompatible.
        Property 'payload' is missing in type 'Action<"decrement">' but required in type '{ payload: number; type: "increment"; }'.
Error: Process completed with exit code 2.

Reading those, seems like 2-3 different issues:

  • buildHooks.ts:1823: an issue with the preSelector parameter , which could be for standard or infinite queries, and how it ends up dragging in the infinite query result flags types
  • map-builders.test-d.ts:56,67: the tests for addCase have @ts-expect-errors, but now it's not erroring on the expected lines
  • map-builders.test-d.ts:58: some overload errors (possibly "just" that the earlier expected errors have now migrated a couple lines down?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    RTK-QueryTypeScriptIssues related to TypeScript.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions