Skip to content

Type error in @trpc/server with TS 4.6 #1588

Description

@garronej

Hi @KATT,
Thank you for this great library.

I am reporting that the server types need updates after the latest typescript release (4.6):

node_modules/@trpc/server/dist/declarations/src/TRPCError.d.ts:7:14 - error TS2416: Property 'cause' in type 'TRPCError' is not assignable to the same property in base type 'Error'.
  Type 'unknown' is not assignable to type 'Error | undefined'.

7     readonly cause?: unknown;
               ~~~~~


Found 1 error in node_modules/@trpc/server/dist/declarations/src/TRPCError.d.ts:7

image

Best regards

Activity

  1. KATT commented on Mar 2, 2022

    @KATT
    Member

    You probably want to enable skipLibCheck. I'll have a look at this when I can

  2. sachinraja commented on Apr 3, 2022

    @sachinraja
    Member

    Solved this while working on #1597. The issue is that in es2022 a cause property was added. Not sure how to fix this without doing a breaking change, but we should probably just have our cause type conform to the TypeScript one. Looks like this was a known issue though:

    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore https://github.com/tc39/proposal-error-cause
    super(message, { cause });

  3. sachinraja commented on Apr 4, 2022

    @sachinraja
    Member

    Fixed on the next branch

  4. ArnaudBarre commented on May 3, 2022

    @ArnaudBarre

    For people running into this (skipLibCheck strangely doesn't work), change lib option in tsconfig to ES2021 (instead of ESNext/ES2022)

  5. github-actions commented on Oct 4, 2022

    @github-actions
    Contributor

    This issue has been locked because it had no new activity for 14 days. If you are running into a similar issue, please create a new issue. Thank you.

  6. locked as resolved and limited conversation to collaborators on Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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