mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 09:36:27 +00:00
utils: fix defined()
NonNullable means both not undefined and not null.
This commit is contained in:
@@ -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?];
|
||||
|
||||
Reference in New Issue
Block a user