In the user interface, the parameter c
is mandatory only if the parameter a
is set to true
.
interface IArguments {
a: boolean,
b: string,
c: string
}
The solution below seems to be effective, but how can I exclude the c
parameter in the first scenario? I used a type
since an interface
would result in an error.
type TArguments = {
a: true,
b: string,
c?: string
} | {
a: false,
b: string,
c: string
};