Closed naveen-bharathi closed 4 months ago
For any valibot schema that uses intersect, InferInput always infers intersect as type never
InferInput
intersect
never
For the below code, the v.InferInput infers typeof eventSchema as never
v.InferInput
typeof eventSchema
This started in the first pre-release v0.31.0-rc.0 and still happens in the latest pre-release v0.31.0-rc.4
import * as v from 'valibot' const eventSchema = v.intersect([ v.pipe( v.object({ name: v.pipe( v.string(), v.trim(), v.maxLength(128), ), startDate: v.date(), endDate: v.date(), }), v.check(({ startDate, endDate }) => startDate < endDate), ), v.variant('hasCelebrity', [ v.object({ hasCelebrity: v.literal(true), celebrity: v.literal('Fabian Hiller'), }), v.object({ hasCelebrity: v.literal(false), celebrity: v.null_(), }), ]), ]) type EventSchemaT = v.InferInput<typeof eventSchema> // infers as 'never' (all the time)
Thanks for reporting this. I will fix it and release a new version.
v0.31.0-rc.5 is available
Many Thanks @fabian-hiller You're a super star ⭐
For any valibot schema that uses intersect,
InferInput
always infersintersect
as typenever
For the below code, the
v.InferInput
inferstypeof eventSchema
asnever
This started in the first pre-release v0.31.0-rc.0 and still happens in the latest pre-release v0.31.0-rc.4
Screenshot from VSCode Intellisense