Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I’m confused because the comment you replied to said “There are no other mainstream languages with a similar type system, which means it's uniquely easy to do very complex things with type safety.”, but with the examples you gave, I don’t see why other statically typed languages cannot do this. Or are you just referring to the benefits in general and not a TS specific aspect?


> I don’t see why other statically typed languages cannot do this

It's not that they can't (mostly), it's that it's much harder.

TypeScript gives you a lot of strict typing for free. You can just throw data around, and TypeScript keeps track of its type. If you paste a blob of JSON into TypeScript, there's a new type created behind the scenes, and you can even reuse it with very little extra code.

The magic parts are the structural typing (overlaps quite a bit with duck typing) and type inference. It means that even your basic JavaScript with zero type annotations are type-checked against each other. If you just feed JavaScript into TypeScript, you'll uncover a lot of errors you didn't know were there.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: