elysia
elysia copied to clipboard
Cannot use Plain Typebox Types for Schema
What version of Elysia.JS is running?
1.0.25
What platform is your computer?
No response
What steps can reproduce the bug?
Try to use a schema, created with TypeBox for an HTTP endpoint.
What is the expected behavior?
No type errors
What do you see instead?
Type error: schema.d.mts(21, 5): '[Kind]' is declared here.
Additional information
Until recently, this worked for me. I double-checked and this issue did not occur in 1.0.24. From my point of view, it makes sense to define types in typebox outside of elysia. This way I can reuse my schema in other places without having elysia as a shared dependency.
I've been facing the same issue.
Even when using "drizzle-typebox" with PostgreSQL as shown here https://elysiajs.com/integrations/drizzle.html.
svi3c have you found a workaround?
svi3c have you found a workaround?
Just override typebox version in package.json
"overrides": {
"@sinclair/typebox": "^0.32.15"
},
I was coming to report the same issue, but this issue showed up only in the new version v1.1
same here the solution from kravetsone worked thanks
svi3c have you found a workaround?
Just override typebox version in
package.json"overrides": { "@sinclair/typebox": "^0.32.15" },
This worked for me, thanks!
This does not work in a monorepo setup.
This does not work in a monorepo setup.
override tip works
"overrides": {
"@sinclair/typebox": "0.33.17"
},
This doesn't seem to be working. I have both my packages set at the same typebox version. Have deleted node modules, restarted typescript & editor. This is migrating from a fastify project using 0.33.17.
server.post('/test', async ({ body }) => {
console.log({body})
return body.name; // 'body' is of type 'unknown'.
}, {
body: t.Object({ // Property '[Kind]' is missing in type 'TObject<{ name: TString; }>' but required in type 'TSchema'
name: t.String(),
})
});
Any suggestions? I'll try downgrade to "0.32.34" and report back
Edit: Downgrading works fine.
This issue seems to be solved. I can't reproduce it with
[email protected]
@sinclair/[email protected]
I had installed @sinclair/typebox separately (even though the same version as elysia), which was causing the issue. Removed it and I don't see this error anymore. Now I'm using import { t } from 'elysia' everywhere.