4 ms·
When used as a vehicle to increase productivity TypeScript type files begin to resemble XSD files (XML Schema definitions) if you have ever used those. This te
by austincheney 5y ago
When used as a vehicle to increase productivity TypeScript type files begin to resemble XSD files (XML Schema definitions) if you have ever used those. This tends to become more true the larger a project becomes.
So TypeScript is to JavaScript as XSD is to XML.
The analogy isn't perfect, but it's close. The analogy doesn't seem to work for DOM composition at all.
I mentioned TypeScript used for productivity. What that means is not reducing code authorship time, but instead reducing time everywhere else such as maintenance and refactoring time. The common use cases are restricting primitives to unions of accept values where appropriate, defining functions to use required typed arguments and typed output, and defining all objects against respective static types. You want your editor to yell at you as you are making code changes when things don't fit as you intended opposed to finding these problems at execution time.
- frosted-flakes 5y agoI recently wrote an XSD file for a fairly complex XML document format that is mostly hand-authored. It's amazing, and I agree with the analogy. VS Code even picked up on it and started to suggest valid values and highlight errors. XML seemed like the wild west before, like JS, but XSD tamed it for me.
- DangitBobby 5y agoWhen you're working on something where requirements are changing and function signatures are changing (I'm looking at you, every frontend codebase ever written), having your editor yell at you about types until you've fixed everything really cuts down on bugs.