Bug Report
π Search Terms
in keyword, narrow, nullable, NonNullable, generic constraint
π Version & Regression Information
β― 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.
This was originally reported by @jcalz here
Bug Report
π Search Terms
in keyword, narrow, nullable, NonNullable, generic constraint
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
The generic version of this function is reporting an error on the
inoperator but the non-generic one isn'tπ Expected behavior
I believe that both of them should not error.
This was originally reported by @jcalz here