Skip to content

Commit 1ba1d1d

Browse files
authored
closes basarat#497 🌹
1 parent 08a0230 commit 1ba1d1d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docs/types/typeGuard.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,15 @@ if (foo.bar) {
202202
});
203203
}
204204
```
205+
206+
### null and undefined with `strictNullChecks`
207+
208+
TypeScript is smart enough to rule out `null` and `undefined` with a `== null` / `!= null` checks. E.g.
209+
210+
```ts
211+
function foo(a?: number | null) {
212+
if (a == null) return;
213+
214+
// a is number now.
215+
}
216+
```

0 commit comments

Comments
 (0)