typescript specify type inside destructuring code example
Example: destruct type definition typescript
interface User {
name: string;
age: number;
}
const obj: any = { name: 'Johnny', age: 25 };
const { name, age }: User = obj;
interface User {
name: string;
age: number;
}
const obj: any = { name: 'Johnny', age: 25 };
const { name, age }: User = obj;