This Cheatsheet collates advice and utilities from real case studies of teams moving significant codebases from plain JS or Flow over to TypeScript. It makes no attempt to convince people to do so, but we do collect what few statistics companies offer up after their conversion experience.
⚠️ This Cheatsheet is extremely new and could use all the help we can get. Solid advice, results, and up to date content all welcome.
General Conversion approaches
- Level 0: Don't use TypeScript, use JSDoc
- See our JSDoc section
- Level 1B: Total rename to TypeScript from the start
- "Just rename all .js files to .ts"?
- use the loosest, bare minimum settings to start with
- Level 2: Strict TypeScript
Misc tips/approaches successful companies have taken
@ts-ignoreon compiler errors for libraries with no typedefs
- pick ESLint over TSLint (source: ESLint and TS Roadmap). You can convert TSlint to ESlint with this tool.
- webpack loader:
ts-loader? (there is some disagreement in community about this - but read awesome's point of view)
- Webpack config:
Special note on
ts-loader and 3rd party libraries: https://twitter.com/acemarke/status/1091150384184229888
Academic Studies of Migration
Our central finding is that both static type systems find an important percentage of public bugs: both Flow 0.30 and TypeScript 2.0 successfully detect 15%!
Misc migration stories by notable companies and open source
- Adopting TypeScript at Scale - AirBnB's conversion story and strategy
- Tiny - Talk from ForwardJS here
- Slack (podcast)
- Netflix adoption story
- Heap - How we failed, then succeeded, at migrating to TypeScript
- Jest's migration (PR)
- Expo's migration (issue)
- Google Workbox migration
- Chrome Dev Tools related issues
- Atlassian's migration (PR)
- Yarn's migration (issue)
- React Native CLI
- React Router
- Docusaurus v2
- Hasura Console
- Dojo 1 -> 2 migration