Closed
Description
TypeScript Version: 2.4.1
Code
type Foo = { bar: string };
declare function foos(f: Foo);
declare function foos(f: Foo[]);
function foos2(f: Foo | Foo[]) {
foos(f);
// Argument of type 'Foo | Foo[]' is not assignable to parameter of type 'Foo[]'.
// Type 'Foo' is not assignable to type 'Foo[]'.
// Property 'length' is missing in type 'Foo'.
}
Expected behavior:
foos
accepts Foo
and Foo[]
. foos2
accepts Foo | Foo[]
. I think foos2
can just pass its argument to foos
without problems.
Actual behavior:
Argument of type 'Foo | Foo[]' is not assignable to parameter of type 'Foo[]'.
Type 'Foo' is not assignable to type 'Foo[]'.
Property 'length' is missing in type 'Foo'.