Reduce void | undefined only in conjunction with subtype reduction (#42846)

* Reduce void | undefined only in conjunction with subtype reduction

* Accept new baselines

* Add regression test
This commit is contained in:
Anders Hejlsberg
2021-02-17 14:48:07 -10:00
committed by GitHub
parent d640313ff2
commit 412ecbc291
16 changed files with 129 additions and 23 deletions

View File

@@ -0,0 +1,13 @@
// @strict: true
// Repro from #42786
function isDefined<T>(value: T | undefined | null | void): value is T {
return value !== undefined && value !== null;
}
declare const foo: string | undefined;
if (isDefined(foo)) {
console.log(foo.toUpperCase());
}