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
The user noticed that schema.pipe(S.optional) is not working anymore and received an error message stating that the 'this' context of type 'Schema' is not assignable. Another user confirmed that the syntax has changed and it should now be used as S.optional(schema). The user mentioned that they have already migrated their codebase and luckily didn't encounter too many occurrences of this issue.
Key takeaways:
The syntax for using S.optional has changed.
Instead of schema.pipe(S.optional), it should now be used as S.optional(schema).
This might be due to the presence of different overloads in the optional signature. In both cases above, the inferred schema is Schema<unknown, unknown>.
I'm unsure about how to resolve this issue. However, isn't tacit usage never recommended?
This might be due to the presence of different overloads in the optional signature. In both cases above, the inferred schema is Schema<unknown, unknown>.
I'm unsure about how to resolve this issue. However, isn't tacit usage never recommended?
While tacit usage is never recommended pipe is kind of an exceptional case, otherwise we could also say that pipe([0, 1], ReadonlyArray.map((n) => n + 1) is discouraged.
Re overloads, this is indeed the issue, namely overload selection, I think we need to decide if the reason we have overloads is absolute necessity or if we can encode what we do with overloads with a conditional return type (that would solve tacit usage).
It's up to @gcanti if you decide that overloads are needed then feel free to close the issue as "intended behaviour"
Summary
The user noticed that
schema.pipe(S.optional)
is not working anymore and received an error message stating that the 'this' context of type 'Schema' is not assignable. Another user confirmed that the syntax has changed and it should now be used asS.optional(schema)
. The user mentioned that they have already migrated their codebase and luckily didn't encounter too many occurrences of this issue.Key takeaways:
S.optional
has changed.schema.pipe(S.optional)
, it should now be used asS.optional(schema)
.Discord thread
https://discord.com/channels/795981131316985866/1193893038557249566
The text was updated successfully, but these errors were encountered: