I have this object:
const ABCD = {
a: 1,
b: 2,
c: 3,
d: 4
}
I can destructure it, collect the rest of it using the "spread" operator, and type the variables like this:
const {a, b, ...restOfIt}: {a: number, b: number} = ABCD;
But how do I also type the restOfIt
on the same line? The following all fail:
const {a, b, ...restOfIt}: {a: number, b: number, ...restOfIt: any} = ABCD;
const {a, b, ...restOfIt}: {a: number, b: number, restOfIt: any} = ABCD;
TypeScript playground here