Closed aleclofabbro closed 3 weeks ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
next-safe-action-playground | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Sep 26, 2024 9:34pm |
@aleclofabbro is attempting to deploy a commit to the Edoardo Ranghieri's projects Team on Vercel.
A member of the Team first needs to authorize it.
HA!
It crossed my mind the primitive union may need to contain symbol
too ! S[K] extends number | string | boolean | bigint | symbol
@aleclofabbro seems good to me! If the union needs to include symbol
too, please push a commit with that and then I'll merge the PR, after testing it. Thank you!
closed in favor of #284
returnValidationErrors()
typechecking fails when a property is a primitive-object-intersection type (typical case of branded type).returnValidationErrors()
refers totype SchemaErrors<S>
for typings the purpose oftype SchemaErrors<S>
as is:is to map
S
properties conditionally: if propertyS[K]
isobject | null | undefined
maps toPrettify<VEList & SchemaErrors<S[K]>>
else (propertyS[K]
is primitive) maps toVEList
the issue arises when property
S[K]
is a branded primitive type. Branded primitive types are typically an intersection of a primitive with an object holding the brand (e.g.type email = string & { [k in brand_prop_type]: unique symbol }
)type SchemaErrors<S>
mapping condition considers branded-primitive-types as object, mapping them incorrectly, and finally leading toreturnValidationErrors()
type errorsProposed changes
the issue is resolved by simply reversing the condition:
this way any primitive - even when intersected - is eagerly catched and properly managed, keeping logic unaltered
Related issue(s) or discussion(s)
This is an improvement of a previous PR https://github.com/TheEdoRan/next-safe-action/pull/273
re #