Open
Description
TypeScript Version: 3.5.2
**Search Terms:extended function type restriction
Code
class C
{
name: string;
constructor(private handler: F)
{
this.name = handler.name;
}
}
type F = (...args: any[]) => any;
type F2 = F & { inject?: string[] }
function f(x: C | F2):C
{
if (typeof x == 'function')
x = new C(f);
return x;
}
Expected behavior: x in function f should be of type C at the point of the return statement
Actual behavior: x is considered as C or F2, apparently because of the combined type (it works well if we replace F2 with F)
Related Issues: #27143