Thursday, June 5, 2014

TypeScript Problem: divorcing type definitions from code = versioning disaster

We use TypeScript. We also use a lot of 3rd party code such as Angular. It turns out one of the nice things about using TypeScript along with 3rd party code is that a lot of 3rd party code has type definitions maintained at https://github.com/borisyankov/DefinitelyTyped. You pop these definitions into your code and suddenly your 3rd party code is typed! Hooray!

So here is the trap. Since your type information is no longer released with your code you can now have version mismatch issues between your code and the type definitions for that code. If this happens your tooling which runs off the type information will instruct you to create defects. Not only that, but it will prevent you from building your code when you fix your code because your correct code will no longer obey your type system that is incorrect.

What makes the situation even worse is that the people generating the type definitions are usually not the people writing the code. This makes mismatches even more likely. If TypeScript can't deliver on the promise of type inference and requires random parties to generate type definitions that may or may not match your code then it seems like it has significant problems.

No comments:

Post a Comment