type SomeType<T> = T extends { amount: number } ? T['amount'] : T extends { planet: string } ? T['planet'] : boolean; const x = { planet: 'Mars' }; type MyType = SomeType<typeof x>;
MyType