How to check if optional object property exists?
I’m having trouble getting TypeScript to recognise that an optional property of an object is defined. type OuterKeys = ‘a’ | ‘b’; type Inner = { value: ”; } type Outer = Partial<Record<OuterKeys, Inner>>; const thisGivesError = (key: OuterKeys, outer: Outer) => { if (outer[key]) { console.log(outer[key].value); } } Even though I explicitly check if… Read More How to check if optional object property exists?