Amgelo563
09/28/2022, 12:40 AMTS2531: Object is possibly 'null'.
TS2345: Argument of type 'JsonValue' is not assignable to parameter of type 'string'. Type 'null' is not assignable to type 'string'.
What confuses me is that
⢠Wasn't JsonValue made to always support JSON.parse()?
⢠Why would JsonValue be null if my schema says it's required?
I tried to use
JSON.parse(fetchedValue ?? '{}');
but I get
TS2345: Argument of type 'string | number | boolean | JsonObject | JsonArray' is not assignable to parameter of type 'string'. Type 'number' is not assignable to type 'string'.
which is related to the first mentioned point. Could someone explain to me what is going on? I probably missed something on the wiki or I did something wrongNurul
09/30/2022, 2:22 PMnull,
so I assume that even if your JsonValue field is required in the schema file, null would be considered valid.
export declare type JsonValue =
| string
| number
| boolean
| null
| JsonObject
| JsonArray
Amgelo563
10/01/2022, 12:59 AMNurul
10/14/2022, 2:20 PMtypeof
?
If it is not of type object then you can throw a custom error.Amgelo563
10/15/2022, 4:11 AMNurul
10/19/2022, 12:45 PM