Problem using TSchema from an internally library #1115
-
The library I made myself is typed. The problem is that the ".d.ts" files do not have enough information. in the .d.ts file generated like this: How can I solve it? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
@cesxhin Hi, If you are exporting TypeBox types from your library. You will need to ensure the application is using the same version of TypeBox as your library is. If the versions are different, TypeScript will flag this as an error (this is because the Kind is a unique symbol, and symbols are tracked per package version) If using TypeBox as a dependency, it is usually good to specify it as a For a reference project, take a look at https://github.com/fastify/fastify-type-provider-typebox Does this help? |
Beta Was this translation helpful? Give feedback.
@cesxhin the error just means you have two instances of Typebox imported somewhere in your dependency tree. We recently ran into the same issue and we made sure we only have one version of it in our lock file, but the issue was still there. The problem turned out to be that we were importing it as an ES module (
import
keyword) in one place, and as a CommonJs module (require
) in another. Apparently symbols are tracked separately for CJS and ESM, not only for different versions.