Skip to content

ApolloServerPluginUsageReporting reportTimer has incorrect type #7798

@stijnbe

Description

@stijnbe

Issue Description

In src/plugin/usageReporting/plugin.ts

reportTimer is typed as NodeJS.Timer, it is actually a timeout, so using node 18> types it is incompatible
with clearInterval()

node_modules/@apollo/server/src/plugin/usageReporting/plugin.ts:808:27 - error TS2769: No overload matches this call.
  Overload 1 of 2, '(intervalId: string | number | Timeout | undefined): void', gave the following error.
    Argument of type 'Timer' is not assignable to parameter of type 'string | number | Timeout | undefined'.
      Property '[Symbol.dispose]' is missing in type 'Timer' but required in type 'Timeout'.
  Overload 2 of 2, '(id: number | undefined): void', gave the following error.
    Argument of type 'Timer' is not assignable to parameter of type 'number'.

808             clearInterval(reportTimer);
                              ~~~~~~~~~~~

  node_modules/@types/node/timers.d.ts:76:17
    76                 [Symbol.dispose](): void;
                       ~~~~~~~~~~~~~~~~~~~~~~~~~
    '[Symbol.dispose]' is declared here.


Found 1 error in node_modules/@apollo/server/src/plugin/usageReporting/plugin.ts:808

Link to Reproduction

n/a

Reproduction Steps

Update @types/node to > 18

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