|
|
|
|
|
by yulaow
1460 days ago
|
|
I believe that typescript type system is so flexible, powerful and complex just because it had to be adapted and built around the shortcomings and limitation of javascript. It makes no sense to have something like it if you build a language from the ground up (or if you could just scrap backward compatibility in a bad designed one) |
|
I think an example is how typescript can know, based on the first argument to a listener, what the Event type coming in will be
typescript knows foo is a MouseEvent and bar is a KeyboardEventOf course you could argue that `addEventListener` is just bad design but I feel like there are legit uses to being able to associate an enum or string with type and I haven't seen that feature in other languages I've used.