-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueHigh Priority
Milestone
Description
Hi,
TS Version: 1.4
In the following the first call to doFoo
fails to compile because the overload resolution algorithm picks the general case:
interface Bar {
bar?: number;
baz?: string;
}
interface Foo {
foo(): string;
}
declare function doFoo(kind: 'Foo', bar?: Bar): Foo;
declare function doFoo(kind: string, bar: any): {}
var x = doFoo('Foo', { bar: 1 });
x.foo(); // Error: Property 'foo' does not exist on type '{}'.
var y = doFoo('Foo', <Bar> { bar: 1 });
y.foo(); // Okay
This is a breaking change because it used to work without the need for the cast in 1.3.
I feel this should compile because { bar: 1 }
is compatible with the Bar
interface.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueHigh Priority