Regarding the caveat, this happens because of duck-typing. I think one way you can solve it is using a typeguard with instanceof to assure that visitSquare receives an instance of Square and if not throw some error so you will hopefully see this problem whenever testing
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Very interesting patterns!
Regarding the caveat, this happens because of duck-typing. I think one way you can solve it is using a typeguard with
instanceof
to assure thatvisitSquare
receives an instance ofSquare
and if not throw some error so you will hopefully see this problem whenever testing