This
const { foo: IFoo[] } = bar;
and this
const { foo: Array } = bar;
will reasonably cause
I had scenarios like so:
const { _id } = req.query;
if (_id.contains('whatever')) { // typescript complained
...
}
in which the "req.query" was typed like string | string[] from NextJS... so doing this worked:
const { _id } = req.query as { _id: string };
if (_id.contains('whatever')) { // typescript is fine
...
}
The irony of this is Typescript was correct but I don't want to do the actual programming work to handle strings and string arrays.