Comments (8)
I have a similar problem, when I try to build my api library form another package using tsup I get the error: ../../node_modules/.pnpm/@[email protected]/node_modules/@trpc/server/src/core/initTRPC.ts(64,3): error TS2742: The inferred type of 'create' cannot be named without a reference to '.pnpm/@[email protected]/node_modules/@trpc/server/src'. This is likely not portable. A type annotation is necessary.
When commenting the openapi meta line:
const t = initTRPC
// .meta<OpenApiMeta>() // With this line commented the code compiles
.context<typeof createTRPCContext>().create({
transformer: superjson,
errorFormatter({ shape, error }) {
return {
...shape,
data: {
...shape.data,
zodError:
error.cause instanceof ZodError ? error.cause.flatten() : null,
},
};
},
});
from trpc-openapi.
@MaximilianGaedig Have you found any workaround for this? Im running into the same issue trying to add trpc-openapi
to my api package in a pnpm+turborepo codebase
from trpc-openapi.
Hey @IsaiahByDayah, yea, we're using it in production for a while already, we've just casted it to OpenApiRouter
import { type OpenApiRouter, generateOpenApiDocument } from 'trpc-openapi';
const openApiDocument = generateOpenApiDocument((openApiRouter as OpenApiRouter),{...})
from trpc-openapi.
Hmmm, @MaximilianGaedig this fixed your issue when adding .meta<OpenApiMeta>()
to the initTRPC
chain? Was there any other exports you had to do to get that piece working? I never actually ran into any issues with generateOpenApiDocument
, but even just adding the meta
call throws the "The inferred type of 'create' cannot be named ..."
error when I try to build
from trpc-openapi.
Would you be able to share a link to your codebase? Happy to try and dig through the source myself to figure out if theres anything different between setups
from trpc-openapi.
Hmmm, @MaximilianGaedig this fixed your issue when adding
.meta<OpenApiMeta>()
to theinitTRPC
chain? Was there any other exports you had to do to get that piece working? I never actually ran into any issues withgenerateOpenApiDocument
, but even just adding themeta
call throws the"The inferred type of 'create' cannot be named ..."
error when I try to build
I just left that commented, about the meta calls, I have not had the same happen
Would you be able to share a link to your codebase? Happy to try and dig through the source myself to figure out if theres anything different between setups
Can't do that, sorry, it's a proprietary product
a part of my tsconfig.json which might help:
{
"compilerOptions": {
"incremental": false,
"module": "node16",
"moduleResolution": "node16"
},
"include": [
"src/index.ts"
],
"exclude": [
"node_modules",
"@trpc/server"
]
}
from trpc-openapi.
Oh, strange 🤔. And you guys are able to still get type inference when you set the meta
value for procedures? ie:
export const appRouter = t.router({
sayHello: t.procedure
.meta({ openapi: { method: 'GET', path: '/say-hello' } }) // 👈 this line here
.input(z.object({ name: z.string() }))
.output(z.object({ greeting: z.string() }))
.query(({ input }) => {
return { greeting: `Hello ${input.name}!` };
});
});
from trpc-openapi.
Oh, strange 🤔. And you guys are able to still get type inference when you set the
meta
value for procedures? ie:export const appRouter = t.router({ sayHello: t.procedure .meta({ openapi: { method: 'GET', path: '/say-hello' } }) // 👈 this line here .input(z.object({ name: z.string() })) .output(z.object({ greeting: z.string() })) .query(({ input }) => { return { greeting: `Hello ${input.name}!` }; }); });
we might be not using a part of this, well we have those meta tags for sure, but we don't use the types from that directly, we generate this openapi file and then use it in another package where we have an openapi-fetch client from that
from trpc-openapi.
Related Issues (20)
- Switching to using zod-openapi from zod-to-jsonschema to solve things like definition? HOT 4
- Support for examples key
- `createOpenApiNuxtHandler` should also export `createOpenApiNitroHandler`
- Support for catchall segments
- GET request interference for query parameters HOT 2
- Support for server-side events?
- Unknown Procedure Type - Next.js App Router HOT 4
- Support for Hono
- `trpc-openapi` tanks our Intellisense performance by 100% HOT 3
- trpc 11 HOT 6
- NextJS app router support HOT 3
- encoded path params are not parsed correctly HOT 1
- Question : input and output must be z.object ?
- Query param not working in example/with-nuxtjs
- Support customizing an error response body
- `z.intersection()` throws error when used as the `input` for trcp router
- Support For t3-app Next js 14 with app router HOT 5
- Subscriptions are not supported by OpenAPI v3
- Support OpenAPI V3 tags
- Outdated fastify example?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trpc-openapi.