Closed
Description
Bug Report
π Search Terms
in keyword, narrow, nullable, NonNullable, generic constraint
π Version & Regression Information
- This is related to the upcoming TS 4.9 release that comes with the improved support for the in keyword
β― Playground Link
Playground link with relevant code
π» Code
export function isHTMLTable<T extends object | null>(table: T): boolean {
return !!table && 'html' in table; // Type 'NonNullable<T>' may represent a primitive value, which is not permitted as the right operand of the 'in' operator.(2638)
}
export function isHTMLTable2(table: object | null): boolean {
return !!table && 'html' in table; // no error
}
π Actual behavior
The generic version of this function is reporting an error on the in
operator but the non-generic one isn't
π Expected behavior
I believe that both of them should not error.