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
How do you get the underlying type T from Any.Type<T>?
import{Test,Any}from"ts-toolbelt";const{checks, check}=TesttypeRootType=number;typeWrapped=Any.Type<RootType>;typeUnwrapped=Any.ExtractType<Wrapped>;// This is what I am looking forchecks([check<Unwrapped,RootType,Test.Pass>(),])
Heres an example of where you would use it:
import{Any}from"ts-toolbelt";import{Either}from"fp-ts/lib/Either";// The library exports the following API to create terms given a object containing values// It returns the module but with the wrapped opaque sub-typesexporttypeTerm<TextendsRecord<string,any>>={[KinkeyofT]: Any.Type<T[K],K>;};// This is really what I would like to work, or ask if there is an existing feature// This looks like it should work.. and I have tried messing around with this for the last 2 hourstypeExtractType<TextendsAny.Type<infer V>>=V;// I wish to export an additional API parameterized with a type created using Term/1exporttypeEncode<TextendsRecord<string,any>>={[KinkeyofT]: (value: ExtractType<T[K]>)=>Either<Error,T[K]>;};
Here is how I desire to use the above generic types:
import{Term,Encode}from"./library.d"import*asEfrom"fp-ts/lib/Either";typeMyTerm=Term<{Age: number;}>// I want to type the encode function from number -> Any.Type<Number>, ignoring the MaybeconstencodeAge: Encode<MyTerm>["Age"]=(age)=>{if(age<0)returnE.left(newError("Age out of bounds"));elsereturnE.right(ageasMyTerm["Age"]);};
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
馃崺 Feature Request
How do you get the underlying type T from
Any.Type<T>
?Heres an example of where you would use it:
Here is how I desire to use the above generic types:
The text was updated successfully, but these errors were encountered: