2 ms·
He lost me at the first example: ```ts user?.name ?? "" ``` The issue isn't the nullish coalescing, but trying to treat a `string | null` as a string and just
by vadansky 10mo ago
He lost me at the first example:
```ts
user?.name ?? ""
```
The issue isn't the nullish coalescing, but trying to treat a `string | null` as a string and just giving it a non-sense value you hope you'll never use.
You could have the same issue with `if` or `user?.name!`.
Basically seems the issue is the `""`. Maybe it can be `null` and it should be `NA`, or maybe it shouldn't be `null` and should have been handled upstream.