Skip to content

v.optional output type is broken #935

Closed
@sbking

Description

I believe this bug was introduced in v1.0.0-beta.3. When wrapping a transform schema in v.optional with a default value, the inferred output type is now a union including the type of the default value. However, at runtime the default value is still parsed through the transform schema.

Tricky to explain, so here is a playground example.

The schema will always return a number, but now TypeScript says it will return number | "10"

Metadata

Assignees

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentationpriorityThis has priority

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions