[wasm] Give is_nullish() a type guard type (#69473)
authorAleksey Kliger (λgeek) <aleksey@lambdageek.org>
Wed, 18 May 2022 12:43:46 +0000 (08:43 -0400)
committerGitHub <noreply@github.com>
Wed, 18 May 2022 12:43:46 +0000 (08:43 -0400)
commita598ebb67973f03b1d6b3fd6c50f75bae3fe1c51
tree9961973e5580b59890bb7c01733539a5888c2297
parent41d6dda1dd4698dfa30c84f31237bd40af22a4fb
[wasm] Give is_nullish() a type guard type (#69473)

* [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'.
```
src/mono/wasm/runtime/strings.ts
src/mono/wasm/runtime/types.ts