Consider the following union type:
type Union = "a" | "b";
Is there a way to add multiple new keys to an object type with conditions? Adding one key with a condition is straightforward:
type Condition<T extends Union> = {
[K in T extends "a" ? "someProp" : never]: string;
}
type Result = Condition<"a">;
// type Result = {
// someProp: string;
// }
However, attempting to add another key with a condition results in a syntax error:
type Condition<T extends Union> = {
[K in T extends "a" ? "someProp" : never]: string;
[K in T extends "a"? "anotherProp": never]: string;
// ~~~~~~~ ~~~~~~~~~~~~ ~
}
Why does trying to perform two checks simultaneously not work here?