TypeScript: 配列から要素の型を取得する
const MyArray = [
{ name: "Alice", age: 15 },
{ name: "Bob", age: 23 },
{ name: "Eve", age: 38 }
];
type T = (typeof MyArray)[number];
const MyArray = [
{ name: "Alice", age: 15 },
{ name: "Bob", age: 23 },
{ name: "Eve", age: 38 }
];
type T = (typeof MyArray)[number];