trpc-openapi icon indicating copy to clipboard operation
trpc-openapi copied to clipboard

Compilation fails with v1.2.0

Open thekaleidoscope opened this issue 1 year ago • 5 comments

The typescript doesn't compile with the upgrade of trpc-openapi spec, errors out with:

project-name:build: ../../node_modules/@trpc/server/src/error/TRPCError.ts(23,19): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Error'.
project-name:build: ../../node_modules/@trpc/server/src/core/internals/config.ts(19,10): error TS2304: Cannot find name 'window'.
project-name:build: ../../node_modules/@trpc/server/src/core/internals/config.ts(20,13): error TS2304: Cannot find name 'window'.

The Project is having the following dependency versions:

"@trpc/client": "^10.25.1",
"@trpc/server": "^10.25.1",
"trpc-openapi": "^1.2.0",
"zod": "^3.20.2",

tfconfig.json:

{
  "compilerOptions": {
    "rootDir": "src",
    "outDir": "dist",
    "target": "es2022",
    "module": "NodeNext",
    "lib": ["es2022"],
    "moduleResolution": "Node",
    "skipLibCheck": true,
    "esModuleInterop": true,
    "strict": true,
    "noImplicitOverride": true,
    "sourceMap": true,
    "declaration": true,
    "declarationMap": true
  }
}

I have confirmed the project works fine with v1.1.2.

thekaleidoscope avatar Jun 28 '23 19:06 thekaleidoscope

facing same V1.1.2 is the last stable version for me

AdarshHatkar avatar Jul 07 '23 18:07 AdarshHatkar

Sadly that is also broken for me. Any way to use this with "noImplicitOverride"?

boredland avatar Nov 23 '23 10:11 boredland

This makes the lib unusable for people using noImplicitOverride = true and fastify, since the fastifyAdapter came with the v1.2.0 release

Cheunn-Panaa avatar Nov 29 '23 14:11 Cheunn-Panaa

noImplicitOverride causes first error ("error TS4114: This member must have an 'override' modifier ...") second error ("error TS2304: Cannot find name 'window'.") can be fixed by addind "dom" to tsconfig compilerOptions.lib but I don't want to add "dom" library it in my backend project

Also I can't understand why there is error for types of "@trpc/server" when skipLibCheck is true. If someone can explain then I can try to fix it

EDIT: Nvm, I found

aliksend avatar Dec 10 '23 13:12 aliksend

I'm also getting errors while compiling. I downgraded to v1.1.2 and am still getting errors. Do anyone have any idea how to fix this?

v1.2.0 and v1.1.2

node_modules/@trpc/server/dist/adapters/aws-lambda/index.d.ts:1:150 - error TS2307: Cannot find module 'aws-lambda' or its corresponding type declarations.

1 import type { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyStructuredResultV2, Context as APIGWContext } from 'aws-lambda';
                                                                                                                                                       ~~~~~~~~~~~~

node_modules/@trpc/server/dist/adapters/aws-lambda/utils.d.ts:1:150 - error TS2307: Cannot find module 'aws-lambda' or its corresponding type declarations.

1 import type { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyStructuredResultV2, Context as APIGWContext } from 'aws-lambda';
                                                                                                                                                       ~~~~~~~~~~~~

node_modules/h3/dist/index.d.ts:28:100 - error TS2552: Cannot find name 'FetchEvent'. Did you mean 'TouchEvent'?

28 declare class H3Event<_RequestT extends EventHandlerRequest = EventHandlerRequest> implements Pick<FetchEvent, "respondWith"> {
                                                                                                      ~~~~~~~~~~

  node_modules/typescript/lib/lib.dom.d.ts:22372:13
    22372 declare var TouchEvent: {
                      ~~~~~~~~~~
    'TouchEvent' is declared here.

node_modules/trpc-openapi/dist/adapters/aws-lambda.d.ts:2:46 - error TS2307: Cannot find module 'aws-lambda' or its corresponding type declarations.

2 import type { Context as APIGWContext } from 'aws-lambda';
                                               ~~~~~~~~~~~~

node_modules/trpc-openapi/dist/adapters/fastify.d.ts:2:33 - error TS2307: Cannot find module 'fastify' or its corresponding type declarations.

2 import { FastifyInstance } from 'fastify';
                                  ~~~~~~~~~

node_modules/trpc-openapi/dist/adapters/next.d.ts:1:49 - error TS2307: Cannot find module 'next' or its corresponding type declarations.

1 import { NextApiRequest, NextApiResponse } from 'next';
                                                  ~~~~~~

node_modules/trpc-openapi/dist/adapters/nuxt.d.ts:6:157 - error TS2344: Type 'void' does not satisfy the constraint 'EventHandlerRequest'.

6 export declare const createOpenApiNuxtHandler: <TRouter extends OpenApiRouter>(opts: CreateOpenApiNuxtHandlerOptions<TRouter>) => import("h3").EventHandler<void>;
                                                                                                                                                              ~~~~


Found 7 errors in 7 files.

Errors  Files
     1  node_modules/@trpc/server/dist/adapters/aws-lambda/index.d.ts:1
     1  node_modules/@trpc/server/dist/adapters/aws-lambda/utils.d.ts:1
     1  node_modules/h3/dist/index.d.ts:28
     1  node_modules/trpc-openapi/dist/adapters/aws-lambda.d.ts:2
     1  node_modules/trpc-openapi/dist/adapters/fastify.d.ts:2
     1  node_modules/trpc-openapi/dist/adapters/next.d.ts:1
     1  node_modules/trpc-openapi/dist/adapters/nuxt.d.ts:6

Dependencies:

  "dependencies": {
    "@trpc/server": "^10.40.0",
    "cors": "^2.8.5",
    "express": "^4.18.2",
    "firebase-admin": "^11.11.1",
    "firebase-functions": "^4.5.0",
    "swagger-ui-express": "^5.0.0",
    "trpc-openapi": "^1.1.2",
    "zod": "^3.22.4"
  },

Here's my tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "outDir": "lib",
    "sourceMap": true,
    "strict": true,
    "target": "es2017",
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "typeRoots": ["src/types", "node_modules/@types"]
  },
  "compileOnSave": true,
  "include": ["src"],
  "exclude": ["src/types", "node_modules"]
}

thecannabisapp avatar Dec 24 '23 15:12 thecannabisapp