Given this Code:
type GameDisplayProps =
| {
as: "link";
id: string;
}
| {
as: "div";
id: undefined;
};
const test = ({as, id}: GameDisplayProps) => `help ${id}`
test({
as: 'div',
id: undefined // why???
});
As you can see, I have to explicitly pass id as undefined in this object, but why? The default behaviour of JS would be to set it to undefined anyways, so why do I have to explicitly type it? Am I doing something wrong or is there a better way to achieve this? (when I don't pass id in ```ts
{ as: 'div', id: undefined}