Typescript type casting when destructuring [duplicate] Typescript type casting when destructuring [duplicate] typescript typescript

Typescript type casting when destructuring [duplicate]


If Typescript can not deduce the type of the result of groupBy you could try asserting it yourself.

function groupBy(o: any) {    return o; // return any}let x = { a: 1, b: "1" }// we know better than tsc and assert the typelet {a, b} = <{ a: number, b: string }>groupBy(x);