-
-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add onNoneEncoding to schema.optional #2772
Add onNoneEncoding to schema.optional #2772
Conversation
🦋 Changeset detectedLatest commit: ea7a9b9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 18 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
If this is accepted, we should update the documentation. Tell me if I should do it in this P.R. |
I think it would be better if |
@gcanti I did not see this comment before I answered the other. |
@gcanti why a function |
I've implemented the version without the function so you can check if I understood well. Tell me if the global idea is good and if you think it would be better with a function. |
Mainly for consistency with our typical practices in Effect, although I now realize that |
packages/schema/src/Schema.ts
Outdated
@@ -1933,7 +1971,7 @@ export const optional: { | |||
| (Types.Has<Options, "as"> extends true ? option_.Option<A> : A) | |||
| (Types.Has<Options, "as" | "default" | "exact"> extends true ? never : undefined), | |||
never, | |||
"?:", | |||
Types.Has<Options, "onNoneEncoding"> extends true ? ":" : "?:", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same applies here, it should be "?:"
as before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, sorry! I'm fixing that quickly
Why not having define types that are re-used in both overloads? It feels a bit painful to have to update both every time but there might be some reasons I don't know of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, now that the type is quite big, it makes even more sense to define the type only once
I did the change! I was taking inspiration from |
@vinassefranche I'd propose a couple of improvements WDYT? https://github.com/Effect-TS/effect/commits/2772-local/ |
@gcanti Great! I wanted to add types tests but did not know where to add them and forgot to ask.
How do I integrate your commits in my branch. Can you do it on your own? Do I have to cherry-pick them? |
If you're okay with the changes, I think I can push to your branch. Wait, let me try... |
lol no, I can't do it. Please just copy the changes if you're okay with them |
you should be able to, repo has the setting to allow it |
ok, this time it seems to have worked |
Great! Should I push my additional type tests? |
Type
Description
This adds
onNoneEncoding
option toschema.optiona
when used with{as: "Option"}
. I took inspiration fromOptionFromNullishOr
Without
onNoneEncoding
, the prop gets removed from the containing StructWith
onNoneEncoding
, the prop is kept with the value being the value ofonNoneEncoding
Related
N/A