Hello ! As I said in another comment the aim of this example is to understand what is a Typeguard ! My example doesn't reflect the reality since as you said, Duck can be identificated as Fish !
In a real project you should use another way to make the difference between each class :)
In a real project you should use another way to make the difference between each class
Indeed; that was precisely my point: it's an ill-conceived example and demonstrates how not to use Typescript. There's little point demonstrating that functionality exists if you don't also demonstrate the thought processes required to use it properly.
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.
Hello ! As I said in another comment the aim of this example is to understand what is a Typeguard ! My example doesn't reflect the reality since as you said, Duck can be identificated as Fish !
In a real project you should use another way to make the difference between each class :)
Thank you for your comment a lot !
Indeed; that was precisely my point: it's an ill-conceived example and demonstrates how not to use Typescript. There's little point demonstrating that functionality exists if you don't also demonstrate the thought processes required to use it properly.