utils: fix defined()

NonNullable means both not undefined and not null.
This commit is contained in:
David Lechner
2022-04-06 18:16:21 -05:00
parent 158e8f2693
commit c29ca56658
+1
View File
@@ -20,6 +20,7 @@ export function assert(condition: boolean, message: string): asserts condition {
*/
export function defined<T>(obj: T): asserts obj is NonNullable<T> {
assert(obj !== undefined, 'undefined object');
assert(obj !== null, 'null object');
}
export type Maybe<T> = [T?, Error?];