You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When defining a Pinia ORM model in TypeScript, optional fields must be typed as field: type | null because the save method of Pinia ORM repos converts unset values (null, undefined) to null.
However, the usual TypeScript way is declaring an optional field as field?: type, which treats an unset value as undefined. Furthermore, TypeScript's optional chaining (a?.b?.c) and utility types (Required<T>, Partial<T>, etc.) also revolve around the undefined value.
My proposition is to replace the usage of null for unset values with undefined. This seems fairly easy and is rather a matter of acceptance by/relevance to the project.
Additional information
Would you be willing to help implement this feature?
I think you are right. But changing this, is something for v2 i think. Because it's a huge breaking change.
But i could already implement this behaviour with a feature flag.
Describe the feature
When defining a Pinia ORM model in TypeScript, optional fields must be typed as
field: type | null
because thesave
method of Pinia ORM repos converts unset values (null, undefined) to null.However, the usual TypeScript way is declaring an optional field as
field?: type
, which treats an unset value as undefined. Furthermore, TypeScript's optional chaining (a?.b?.c
) and utility types (Required<T>
,Partial<T>
, etc.) also revolve around the undefined value.My proposition is to replace the usage of null for unset values with undefined. This seems fairly easy and is rather a matter of acceptance by/relevance to the project.
Additional information
Final checks
The text was updated successfully, but these errors were encountered: