Two signatures I thought were the same are behaving differently from each other:
type FooType = [ string, number? ]
const fooAr = [ "foo" ] as FooType // compiles
type BarType = [ string, number | undefined ]
// Conversion of type '[string]' to type 'BarType' may be a mistake because neither type sufficiently overlaps with the other.
const barVar = [ "bar" ] as BarType
I wouldn't mind except I'm inferring the type from a library and can't change the signature. Is this how Typescript is supposed to behave?
== Edit
Was hoping it followed the object type behavior:
type FooType = { foo: string, bar: string | undefined }
const fooOjb = { foo: "abc" } as FooType // compiles
undefinedare different.