DEV Community

loading...

Discussion on: How I improve my skills in Typescript

Collapse
codeozz profile image
CodeOzz Author

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 !

Collapse
blindfish3 profile image
Ben Calder • Edited

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.