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
I'm trying to use this monads library to convert my nullable / undefined fields from my API calls, to rust-style Options. With it I can provide compile-time checking for nullable fields.
I get the following error from the example below.
'OptionT' only refer to a type, but is being used as a value here.
import'reflect-metadata';import{jsonObject,jsonMember,TypedJSON}from'typedjson';import{Some,OptionasOptionT}from"@sniptt/monads";
@jsonObjectclassMyDataClass{
@jsonMemberprop1?: string;
@jsonMemberprop2: OptionT<string>;}letserializer=newTypedJSON(MyDataClass);serializer.mapType(OptionT,// Option doesn't work here for some reason, because its generic?{deserializer: json=>json==null ? json : Some(json),serializer: value=>value==null ? value : value.unwrap(),});constobj=newMyDataClass();obj.prop1="opt";obj.prop2=Some("22");constjson=serializer.stringify(obj);constobject2=serializer.parse(json);console.log(json);console.log(object2);object2instanceofMyDataClass;// true
I'm trying to use this monads library to convert my nullable / undefined fields from my API calls, to rust-style Options. With it I can provide compile-time checking for nullable fields.
I get the following error from the example below.
output
thames-technology/monads#105
The text was updated successfully, but these errors were encountered: