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