Snippet:
export type TestType =
| string
| number
| { value?: string, label?: string }
| { num1: number, num2: number }
| null;
const data: TestType;
data?.value // error;
Error Message:
Property 'value' does not exist on type 'TestType'.
Property 'value' does not exist on type 'string'
Solution Works in Isolation:
const data: TestType = { num1: 10, num2: 20 };
console.log(data.num1);
However, the issue arises when this type is used in an array of objects where it can be one of the described types at runtime