Hey all,
suppose an object like
const foo = {
someProp: {
test: false
}
} satisfies Record<string, {bar?: string, test: boolean}>
Is it possible to check whether entries in foo have property type and if so, access the type?
E.g suppose we want to access type in a function like
declare function fn<
K extends keyof typeof foo,
// T won't work because 'type' does not exist on foo :(
T extends typeof foo[K]['type']
>(): void
The extend of T unfortunately won't work, because type does not exist on foo[K], but is there a way to check if type exist and then being able to access the type and if not, return a default value?