This
const { foo: IFoo[] } = bar;
and this
const { foo: Array } = bar;
will reasonably cause
A follow-up to my own question.
Types don't need to be specified for object properties because they are inferred from destructured object.
Considering that bar
was typed properly, foo
type will be inferred:
const bar = { foo: [fooValue], ... }; // bar type is { foo: IFoo[], ... }
...
const { foo } = bar; // foo type is IFoo[]
Even if bar
wasn't correctly typed (any
or unknown
), its type can be asserted:
const { foo } = bar as { foo: IFoo[] }; // foo type is IFoo[]