gist.github.com
A list of findings after experimenting with TypeScript
TypeScript TypeScript (TS) is a language that promises "JavaScript that scales". After running a number of investigationary projects, TS has been found lacking for a number of reasons that can be summarised in the following categories. 1. Configuration 2. Permissiveness 3. Strict mode 4. Lock-in 5. Progressive inclusion … # Permissiveness Without `strict mode`, TS will allow a large number of type unsafe actions to occur, giving the user the feeling of writing solid code and perhaps forgoing unit tests under the assumption the type system will save them. Examples of what is allowed by the compiler without strict mode include - Implicit `any` - Implicit use of `this` - No checking of `null` or `undefined` - No checking that properties are initialised - No checking on function types. … # Strict mode A strict mode exists to solve all these problems, however it comes with its own problems. It often results in unhelpful error reporting and as it combines type checking with TS Lint passesing, can often waste the developers time in a loop that can only be solved by writing code in an unreasonable way or configuration. … ### Strict mode: Compiler error messages are unhelpful An example using `Styled-Components` is given. When using this library and writing CSS within a template literal, a mistake will force the compiler to fail. … #### Strict mode: Unhelpful tooling The tooling can occasionally fail to watch files, or have conflicts between the TS compiler running the terminal and the linting happening within the editor. Since strict mode requires everything to be in order to compile at all, this can lead to frustations. In addition, the tooling never suggests *how* to type somethng, as ReasonML and Flow often do. This leads to the developer having to hunt down typings for things like React events by herself.
Related Pain Points4件
TypeScript does not provide the type safety it claims to offer
6TypeScript's type system provides a false sense of security. The transpiler cannot truly know type information due to JavaScript's dynamic nature, and empirical research shows TypeScript code contains equal or more bugs than JavaScript code, with longer bug fix times.
Tooling Conflicts and File Watching Issues in Strict Mode
6TypeScript tooling occasionally fails to watch files or has conflicts between the TS compiler running in the terminal and linting happening in the editor. Since strict mode requires everything to compile, these issues cause significant frustration.
TypeScript type system complexity leads to overuse and poor patterns
5TypeScript's extensive type features encourage developers to overuse strict mode, union types, type assertions, and complex type definitions, which actually increase code complexity without reducing bugs or improving readability. This represents a fundamental DX problem where the language design incentivizes anti-patterns.
Lack of Tooling Suggestions for Type Definitions
4TypeScript tooling never suggests how to type something properly, unlike other typed languages such as ReasonML and Flow. Developers must manually hunt down and write correct type definitions, which is time-consuming and error-prone.