Open samchungy opened 1 year ago
If this isn't desirable I can hide the type changes behind .nonempty() eg. When you use .nonempty() and .min() it will produce the stricter type
@samchungy Any progress on this?
I need this type
type TypeINeed = [number, number];
type TypeItProduces = [number, ...number[]];
I've used this methonds, but none returned infered type as: [number,number]
{
rooms: z.array(z.number()).nonempty().min(2).max(2).length(2),
rooms: z.number().array().min(2).nonempty(),
rooms: z.number().array().min(2).max(2).nonempty(),
}
Is there a way in the current version?
Hey crew!
We rely on noUncheckedIndexedAccess on our repos so we rely on nonempty array types.
This makes enforcing array type lengths very important.
This proposes enhancements to
min
andlength
checks to create even more accurate types which can work well withnoUncheckedIndexedAccess
.We could type the following
But that would require a little bit of rework to pipe min and max cardinality around and probably isn't all that helpful in general.