mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
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:
13
tests/cases/compiler/voidUndefinedReduction.ts
Normal file
13
tests/cases/compiler/voidUndefinedReduction.ts
Normal 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());
|
||||
}
|
||||
Reference in New Issue
Block a user