You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've got a project setup using pnpm workspaces setup like so
shared
"@sinclair/typebox": "0.32.19"
server
"shared": "workspace:*",
"@sinclair/typebox": "0.32.19"
in shared im exporting a schema
import { Type } from '@sinclair/typebox';
export const bar = Type.Object({});
and in the server im importing it and trying to use it
import { TSchema } from '@sinclair/typebox';
import { bar } from 'shared/schemas'
function foo<T extends TSchema>(schema: T) {}
foo(bar);
but I'm getting the error
Argument of type 'TObject<{}>' is not assignable to parameter of type 'TSchema'.
Property '[Kind]' is missing in type 'TObject<{}>' but required in type 'TSchema'.
Is TSchema the wrong type to use or any other idea why its not working?
The text was updated successfully, but these errors were encountered:
Is TSchema the wrong type to use or any other idea why its not working?
The code you have there looks correct. However, I'm not a familiar with pnpm, so can't provide must assistance there. Some things you can try though.
Ensure all projects are configured as strict (tsconfig.json)
Ensure all projects are configured as either module: CommonJS, or module: NodeNext (tsconfig.json) (these should be the same across projects in your monorepo as TB provides both ESM and CJS versions which are incompatible with each other)
Ensure you only have one version of TypeBox installed.
Give the above a try. If this doesn't solve the issue, if you're able to setup a simple GH reproduction project, I may be able to provide a bit more assistance.
Thanks, in trying to create a repro I found that I had missed "type": "module" in the shared workspace. Once I added that it stopped throwing the error.
I've got a project setup using pnpm workspaces setup like so
in shared im exporting a schema
and in the server im importing it and trying to use it
but I'm getting the error
Is TSchema the wrong type to use or any other idea why its not working?
The text was updated successfully, but these errors were encountered: