I have the following interfaces and types (all of which are open to change)
interface Base {
type: string;
}
interface A extends Base {
type: \"A\";
If you're not going to throw any errors, and isC
is your last rule check-point, couldn't you remove the condition (thus always returning the CThing at the end)?
function doAThingBasedOnTheRuleType(rule: Rule): Thing {
if (isAnd(rule)) {
return DoAndThing(rule);
}
if (isOr(rule)) {
return DoOrThing(rule);
}
if (isA(rule.base)) {
return DoAThing(rule);
}
if (isB(rule.base)) {
return DoBThing(rule);
}
return DoCThing(rule);
}