Reproduction link or steps
- Build https://github.com/angrybacon/scrydrop
- Inspect
dist/index.d.ts
- Notice the schema declarations (
any)
To avoid having to build yourself, you can inspect the code and the published code directly
schemas.ts
export const ScryCountResponseSchema = z. ...;
export const ScrySearchResponseSchema = z. ...;
export const ScrySingleResponseSchema = z. ...;
export type ScryCountResponse = z.infer<typeof ScryCountResponseSchema>;
export type ScrySearchResponse = z.infer<typeof ScrySearchResponseSchema>;
export type ScrySingleResponse = z.infer<typeof ScrySingleResponseSchema>;
index.d.ts
declare const ScryCountResponseSchema: any;
declare const ScrySearchResponseSchema: any;
declare const ScrySingleResponseSchema: any;
type ScryCountResponse = z.infer<typeof ScryCountResponseSchema>;
type ScrySearchResponse = z.infer<typeof ScrySearchResponseSchema>;
type ScrySingleResponse = z.infer<typeof ScrySingleResponseSchema>;
What is expected?
I am not sure whether this is expected from tsdown's perspective, but from a tsdown user's point of view (mine) I was expecting a copy of the full type to be exported and not the any failback/fallback. Unsure what went wrong that it warranted any but my goal is to export the methods and the type that they yield without having the consumer project depend on Zod directly at all
I am not sure whether this is expected from tsdown's perspective
Feel free to label as a feature request accordingly
What is actually happening?
The resulting .d.ts declares schemas as any, making all types that use it also any. One workaround is to exports the schemas (already the case) and then ask the consumer project to also depend on Zod in do the infer<typeof Schema> in its code but that's not an acceptable workaround in my view
Any additional comments?
I've tried to copy the properties a bit naively and with no success
+type Prettify<T> = { [K in keyof T]: T[K] } & {};
-export type Foo = z.infer<typeof FooSchema>;
+export type Foo = Prettify<z.infer<typeof FooSchema>>;
If that's the right direction but the wrong way to go about it I'd be interested
Reproduction link or steps
dist/index.d.tsany)To avoid having to build yourself, you can inspect the code and the published code directly
schemas.tsindex.d.tsWhat is expected?
I am not sure whether this is expected from tsdown's perspective, but from a tsdown user's point of view (mine) I was expecting a copy of the full type to be exported and not the
anyfailback/fallback. Unsure what went wrong that it warrantedanybut my goal is to export the methods and the type that they yield without having the consumer project depend on Zod directly at allFeel free to label as a feature request accordingly
What is actually happening?
The resulting
.d.tsdeclares schemas asany, making all types that use it alsoany. One workaround is to exports the schemas (already the case) and then ask the consumer project to also depend on Zod in do theinfer<typeof Schema>in its code but that's not an acceptable workaround in my viewAny additional comments?
I've tried to copy the properties a bit naively and with no success
If that's the right direction but the wrong way to go about it I'd be interested