In Typescript 3.4, when destructuring an object, you can define the exact response type like this:
interface IResponse {
loading: boolean;
data: any;
error: string;
}
interface IObject {
...
}
const {loading, data, error}:{data: IObject} = myResponseObject;
Essentially, you are transforming the myResponseObject.data: any
type into myResponseObject.data: IObject
type during destructuring. Is this possible?