-
Notifications
You must be signed in to change notification settings - Fork 13k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone
Milestone
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
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone