* [wasm] Give is_nullish() a type guard type
allow callers to refine the type of the argument to just `T` on the false
brach
```
let obj: number | null | undefined = ...
if (is_nullish (obj))
return;
// otherwise obj is known to TS to be 'number'.
```
const result = interned_string_table.get(ptr);
if (is_nullish(result))
throw new Error("internal error: interned_string_table did not contain string after js_string_to_mono_string_interned");
- return result!;
+ return result;
}
function _store_string_in_intern_table(string: string, root: WasmRoot<MonoString>, internIt: boolean): void {
// Evaluates whether a value is nullish (same definition used as the ?? operator,
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator)
-// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
-export function is_nullish (value: any): boolean {
+export function is_nullish<T> (value: T | null | undefined): value is null | undefined {
return (value === undefined) || (value === null);
-}
\ No newline at end of file
+}