I've been working on implementing a Visitor Design pattern, but I keep running into a compilation error that I just can't seem to resolve no matter how many hours I spend trying to find a solution...
Here's my Visitor interface:
export interface Visitor {
visit(a: A): X;
visit(b: B): Y;
}
And here's my Visitor implementation:
export class VisitorImp implements Visitor {
visit(a: A): X {
return a.getX();
}
visit(b: B): Y {
return b.getY();
}
}
Unfortunately, I'm encountering the following compilation error:
Property 'visit' in type 'VisitorImp' is not assignable to the same property in base type 'Visitor'.
Type '(a: A) => X' is not assignable to type '{ (a: A): X; (b: B): Y; }'.
Type 'X' is missing the following properties from type Y
I'm really hoping someone can assist me with this issue because it's starting to drive me crazy!