But when you add new type Duck you will not be able to differentiate pets and fishes from Duck just checking available methods because a Duck can both swim and fly. In that case you will have to turn to Thorsten's explicit kind of an animal.
In the case of your interface growth you will need to use another way to put in the type guard yes. But in this exemple it's overkill to use more properties
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.
But when you add new type Duck you will not be able to differentiate pets and fishes from Duck just checking available methods because a Duck can both swim and fly. In that case you will have to turn to Thorsten's explicit kind of an animal.
In the case of your interface growth you will need to use another way to put in the type guard yes. But in this exemple it's overkill to use more properties