|
|
|
|
|
by frenchy
2014 days 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. |
|