TypeScript for Web Projects, Done Properly
A typed layer over JavaScript that checks types at build time and improves editor support.
On this page
The key figures
- Compilation
- TypeScript compiles to JavaScript
- Strictness
- compiler options control how strict checks are
- Type definitions
- libraries ship or require type packages
- Runtime
- types disappear at runtime and do not validate input
Why this is worth getting right
Types catch a class of bugs before runtime and document intent, at the cost of build complexity.
Do this, not that
Do
- Enable strict mode on new projects
- Type external data explicitly
- Validate untrusted input at runtime too
- Adopt gradually in existing codebases
- Keep type definitions updated
Don’t
- Using any everywhere
- Assuming types validate API responses
- Big-bang migrations
- Type gymnastics that hurt readability
When to bring in help
Our advice Bring in help when migrating a JavaScript codebase.
Where this comes from
- Microsoft Learn — TypeScript
- MDN Web Docs — JavaScript modules
The figures and practices above come from the sources listed.
Working on something like this?
We take on Web Design & Development work for teams who want it done once, properly. Tell us what you are building and we will tell you honestly whether we are the right studio for it. Start a project.
Where to go next
Spotted something wrong? Report an error on this page. We correct on the page and say what changed.