TypeScript strictly typed: the true promise of TypeScript
Cyrille Tuzi
Posted on June 12, 2024
The problem
Over the last decade, as a JavaScript expert, I helped companies of all kinds and sizes. Over time, I detected a series of some recurring major problems in nearly all projects.
One of them is a lack of typing, resulting in a lack of reliability and an exponential decline in productivity.
Yet, all these projects were coded in TypeScript. Should not it guarantee typing like in Java, C# or Rust?
Short answer: no, because by default TypeScript:
- only partially enforces typing
- does not handle nullability
- retains some JavaScript's dynamic typing
These problems can be solved with adequate configuration and the resulting good practices. But for that, even strict mode, if one knows about it, is not enough.
This posts series claims to be a reference about a strong, static and complete typing in TypeScript, and I will try to keep it up to date.
Target audience
This posts series is intended for developers who already know TypeScript and who:
- do not know about strict mode
- do know about strict mode but think it is enough to guarantee sufficient typing
- know languages like Java, C# or Rust and want a similar typing level in TypeScript
- want to increase reliability of their code and reduce the risk of bugs
- want to increase productivity
This posts series is not intended for people who:
- do not like TypeScript and already have a definitive opinion about it
Changelog
- 2024/11/18: dangerous assertions mentioned in part 2 can now be caught by the new
no-unsafe-type-assertion
ESLint rule
Contact
If you want a direct discussion with me:
- preferably via LinkedIn (if you cannot send me a message directly, please add a note to your contact request)
- direct message on X (Twitter)
French version
A French version is available on LinkedIn.
Next part
Before going into the topic's technical core, we will start this posts series with an introduction about why solving the 3 problems above is important for reliability and productivity.
Posted on June 12, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.