Bug Report
🔎 Search Terms
Type predicate, mapped types, narrowing
🕗 Version & Regression Information
Tried with v4.3.5
⏯ Playground Link
Playground link
💻 Code
declareconstareValuesDefined:
<T>(t: T)=>t is {[KinkeyofT]: Exclude<T[K],undefined>}letx={}as{a: string|undefined}|{b: string}if(areValuesDefined(x)){x;// Expected: { a: string } | { b: string }// Actual: { b: string }}🙁 Actual behavior
The type of x, inside the if block, is { b: string }
🙂 Expected behavior
The type of x, inside the if block, should have been { a: string } | { b: string }.
Also the quickinfo of areValueDefined is inconsistent with the what actually the narrowed type is. The quickinfo shows the expected type.

Also the narrowing { b: string } is particularly weird, even if it somehow failed it should have kept the type as it is.
And the narrowing does work in this case...
declareconstareValuesDefined:
<T>(t: T)=>t is {[KinkeyofT]: Exclude<T[K],undefined>}letx={}as{a: string|undefined}|{b: string|undefined}if(areValuesDefined(x)){x;// Expected: { a: string } | { b: string }// Actual: { a: string } | { b: string }}
Bug Report
🔎 Search Terms
Type predicate, mapped types, narrowing
🕗 Version & Regression Information
Tried with v4.3.5
⏯ Playground Link
Playground link
💻 Code
🙁 Actual behavior
The type of
x, inside theifblock, is{ b: string }🙂 Expected behavior
The type of
x, inside theifblock, should have been{ a: string } | { b: string }.Also the quickinfo of
areValueDefinedis inconsistent with the what actually the narrowed type is. The quickinfo shows the expected type.Also the narrowing
{ b: string }is particularly weird, even if it somehow failed it should have kept the type as it is.And the narrowing does work in this case...