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
Hi,
I am migrating a complex zod validation to arktype and use that opportunity to refactor some stuff. The basic premise is that some module is creating parsers to be consumed by other modules.
In some cases the inference with morphs does not work. A parser is always meant to parse unknown types into something. But here the typing of the morph (which extends the succeeded validation?) is used as the input type instead of the regular unknown.
import{type}from"arktype"importtype{Type,Out}from"arktype";typeNullableStr=string|null;// TS2322: Type Type<(In: string | null) => Out<NullableStr>, {}> is not assignable to type Type<(input: unknown) => Out<NullableStr>, {}>// Types of property t are incompatible.// Type (In: string | null) => Out<NullableStr> is not assignable to type (input: unknown) => Out<NullableStr>// Types of parameters In and input are incompatible.// Type unknown is not assignable to type string | nullconstparseStr: Type<(input: unknown)=>Out<NullableStr>>=type("string.trim | null").pipe((value: NullableStr): NullableStr=>value==='' ? null : value);
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I am migrating a complex zod validation to arktype and use that opportunity to refactor some stuff. The basic premise is that some module is creating parsers to be consumed by other modules.
In some cases the inference with morphs does not work. A parser is always meant to parse unknown types into something. But here the typing of the morph (which extends the succeeded validation?) is used as the input type instead of the regular unknown.
Beta Was this translation helpful? Give feedback.
All reactions