typescript how to set type destructured code example
Example 1: destruct type definition typescript
interface User {
name: string;
age: number;
}
const obj: any = { name: 'Johnny', age: 25 };
const { name, age }: User = obj;
Example 2: array destructuring typescript type
function f([a,b,c]: [number, number, number]) {
}