I am encountering a TypeScript error in the code snippet below, even though I specified it as Record<"abc", string>?
interface IFoo {
key ?:
| string
| Record<"abc", string>
| boolean
| string[]
}
const test: IFoo = {key: {abc: "Hi"}}
console.log(test?.key?.abc);
The error message states: Property 'abc' does not exist on type 'string | Record<"abc", string>'.
Property 'abc' does not exist on type 'string'.