I do programming with strikNullCheks option.
When I use ! operator with in operator, I got a following error.
(This is exactly what happens when I use a payload of Redux's Action.)
Is there any way to solve the problem?
Thanks you for reading :)
interface Interface {
AB?: {
a: number;
} | {
b: number[];
}
}
function test(ab: Interface['AB']) {
const ab2 = ('a' in ab!) ? [ab!.a] : ab!.b;
=> error: Property 'a' does not exist on type '{ a: number; } | { b: number[]; }'.
Property 'a' does not exist on type '{ b: number[]; }'.
=> error: Property 'b' does not exist on type '{ a: number; } | { b: number[]; }'.
Property 'b' does not exist on type '{ a: number; }'
}