From da42b3d49b9b624c2b4c26ba15b6459109696a41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Minelli?= <michael@minelli.me> Date: Mon, 3 Jul 2023 23:58:54 +0200 Subject: [PATCH] LazyVal => Bug fix : missing possibly undefined type --- helpers/LazyVal.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/helpers/LazyVal.ts b/helpers/LazyVal.ts index 0217647..ee0d8d4 100644 --- a/helpers/LazyVal.ts +++ b/helpers/LazyVal.ts @@ -1,11 +1,11 @@ class LazyVal<T> { - private val: T = null; + private val: T | undefined = undefined; constructor(private valLoader: () => Promise<T> | T) {} get value(): Promise<T> { return new Promise<T>(async (resolve) => { - if ( this.val === null ) { + if ( this.val === undefined ) { this.val = await this.valLoader(); } @@ -14,11 +14,11 @@ class LazyVal<T> { } reset() { - this.val = null; + this.val = undefined; } get isValueLoaded(): boolean { - return this.val !== null; + return this.val !== undefined; } } -- GitLab