I'm trying to make more peace with TypeScript, since that where things seem to be moving. Learning and Using TypeScript as an App Dev and a Library Maintainer was a good piece. Definitely pro-TS, but admitting some of the challenges, and not worth true fanaticism.
From that page:
- Pros 👍:
- Documentation: static types tell devs what variables look like quickly - especially valuable when working with unfamiliar code
- Compile-time errors: common issues like typos or undefined values can be caught immediately, rather than at runtime; compiler prevents passing invalid values
- Intellisense: type declarations allow IDEs to provide proper autocompletion and type information when writing code
- Refactoring: can confidently rename / delete / extract code, rather than searching and "hope I found all the uses"
- Long-term maintainability: better codebase information for future developers who may rotate on and off the project
- Code Quality: doesn't replace unit tests, but can help minimize errors
- Library Support: most common 3rd-party libs either ship typings, or community has created their own
- Cons 👎:
- Learning Curve: additional syntax and concepts take time to understand, on top of knowing plain JS by itself
- Time to Write Code: literally more code to write out than just plain JS
- Difficulties Typing Dynamic JS: can be difficult to come up with good static types for highly dynamic JS behavior
- Inconsistent/Missing Library Types: not all libs have typings, and quality can vary
- Compilation Time: TS usage can slow down build times
- Over-Emphasis on Type Coverage: some TS users spend too much time trying to achieve "100% perfect static type coverage" of an entire codebase, leading to bizarrely complex types
No comments:
Post a Comment