I have three Typescript types like this:
type Mum = {
stage: "here" | "are" | "some" | "stages";
};
type Dad = {
stage: "more" | "steps" | "that" | "could" | "happen";
};
type Child = Mum | Dad;
and I have a function that consumes Child:
function myFunc(person: Child): void {
switch (person.stage) {
case "here":
//doThings();
}
}
But I don't want to pass in the entire Child type, only the stage. How can I change this function signature so that it accepts a stage without using any, or keeping a manual copy of the string literal about?
function myFunc(stage: any): void {
switch (stage) {
case "here":
//doThings();
}
}