fix: type checking issues for recursive types
This commit is contained in:
@@ -18,12 +18,15 @@ const baseCollectionSchema = z.object({
|
||||
),
|
||||
})
|
||||
|
||||
type Collection = z.infer<typeof baseCollectionSchema> & {
|
||||
folders: Collection[]
|
||||
type Input = z.input<typeof baseCollectionSchema> & {
|
||||
folders: Input[]
|
||||
}
|
||||
|
||||
//@ts-expect-error ~ Recursive type
|
||||
export const V1_SCHEMA: z.ZodType<Collection> = baseCollectionSchema.extend({
|
||||
type Output = z.output<typeof baseCollectionSchema> & {
|
||||
folders: Output[]
|
||||
}
|
||||
|
||||
export const V1_SCHEMA: z.ZodType<Output, z.ZodTypeDef, Input> = baseCollectionSchema.extend({
|
||||
folders: z.lazy(() => z.array(V1_SCHEMA)),
|
||||
})
|
||||
|
||||
|
||||
@@ -23,12 +23,15 @@ const baseCollectionSchema = z.object({
|
||||
headers: z.union([HoppRESTHeaders, z.array(GQLHeader)]),
|
||||
})
|
||||
|
||||
type Collection = z.infer<typeof baseCollectionSchema> & {
|
||||
folders: Collection[]
|
||||
type Input = z.input<typeof baseCollectionSchema> & {
|
||||
folders: Input[]
|
||||
}
|
||||
|
||||
// @ts-expect-error ~ Recursive type
|
||||
export const V2_SCHEMA: z.ZodType<Collection> = baseCollectionSchema.extend({
|
||||
type Output = z.output<typeof baseCollectionSchema> & {
|
||||
folders: Output[]
|
||||
}
|
||||
|
||||
export const V2_SCHEMA: z.ZodType<Output, z.ZodTypeDef, Input> = baseCollectionSchema.extend({
|
||||
folders: z.lazy(() => z.array(V2_SCHEMA)),
|
||||
})
|
||||
|
||||
|
||||
@@ -13,5 +13,5 @@
|
||||
"emitDeclarationOnly": true,
|
||||
"declarationDir": "./dist"
|
||||
},
|
||||
"include": ["src/*.ts"]
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
|
||||
@@ -10,5 +10,5 @@
|
||||
"skipLibCheck": true,
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"include": ["src/*.ts"]
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user