Closed alecmev closed 3 months ago
A better solution would be to figure out how to avoid the recursive inference problem. If we can't find a solution, we could try to limit the recursiveness to a certain depth. Are you interested in exploring this problem?
Related issue at the TS repo: https://github.com/microsoft/TypeScript/issues/38628
Good find! Looking at that issue, how about /** @ts-expect-error */
? TypeScript preserves doc comments.
This may work, but it is a dirty hack. I would prefer an official solution, or that we rethink our implementation. But I will consider it.
This will probably be fixed in the next version.
v0.38.0 is available 🚀
As mentioned in https://github.com/fabian-hiller/valibot/issues/659#issuecomment-2183564529, some prefer to keep
skipLibCheck
off. It's not about being pedantic, it can help explain otherwise cryptic errors (speaking from experience), and puts pressure on the ecosystem to keep their types clean.However, in this case it isn't an easy fix at all (looks like
QuestionMarkSchema
being recursive pushes the limits of inference, https://github.com/microsoft/TypeScript/issues/30134, https://github.com/microsoft/TypeScript/issues/47599). Hit my head for half an hour, to no avail.Thankfully, this repo already has
// @ts-expect-error
peppered throughout:https://github.com/fabian-hiller/valibot/blob/094d9845e4d5c90659ac61d2627dba811568d07a/library/src/types/other.ts#L90-L99
So all that needs to be done is just preserve these in the emitted
.d.ts
. Easier said than done, as I haven't been able to find iftsc
can even do it, but worst case, at least it could be a post-build script just adding these back in aboveQuestionMarkSchema
andQuestionMarkSchemaAsync
, and inside ofTuplePath
.