Are you using the -js-default-initializers=false compiler option? Maybe
this warning should not be reported in that case.

If you aren't using that compiler option, then variables of type Number
will always be initialized to a non-null value. By default, Number defaults
to NaN and can't be set to null. It gets coerced.

--
Josh Tynjala
Bowler Hat LLC
https://bowlerhat.dev/


On Mon, Apr 27, 2026 at 1:52 AM Harbs <[email protected]> wrote:

> We just noticed that if you use the "Nullish coalescing operator" (??) on
> anything which is not an object, it will cuase the compiler to show a
> warning of something like "Comparison between a value of type Number and an
> unrelated type Null.”.
>
> The warning makes some technical sense, but it seems to me like it’s not
> something we want in practice. It makes it less useful on uninitialized
> values.
>
> Thoughts?
>
> Harbs

Reply via email to