If you define the array first, here’s a way to get the Fruit
type
const arrayWithAllFruitsAsvalues = ['apple', 'peach'] as const;
type Fruit = typeof arrayWithAllFruitsAsvalues[number]; // "apple" | "peach"
const objectWithAllFruitsAsKeys: {
[ key in Fruit ]: any
} = { apple: '', peach: '' }