Say I have a function in which I want to only allow a property if another property is present.
I tried to do it like this, but it returns with error Property 'c' does not exist on type 'A'.
type A = {
a?: string;
} & ({ b: string; c?: string } | { b?: string });
const sad = (props: A) => {
const { a, b } = props;
const { c } = props; // Property 'c' does not exist on type 'A'.
return { a, b };
};
Any solutions to this?