3 ms·
This is actually more similar to what is going on above: function ok_or<T>(x: T | null, msg: string): T | Error { if (x === null) return new Error(msg);
by frenchy 6y ago
This is actually more similar to what is going on above:
function ok_or<T>(x: T | null, msg: string): T | Error {
if (x === null) return new Error(msg);
return x;
}
Thrown values (or exceptions if you like that term) are very much not type-safe in TypeScript.