DEV Community

Cover image for Embracing gradual typing — Strategies for adopting TypeScript into a large project (Talk)
Thai Pangsakulyanont
Thai Pangsakulyanont

Posted on

Embracing gradual typing — Strategies for adopting TypeScript into a large project (Talk)

There are many challenges when trying to adopt TypeScript into your JavaScript project. Your project may already have tons of untyped files, changing your build system can sound risky, and your colleages may ask if the cost of investing in migrating all the code to TypeScript would be worth the effort or not.

Some may argue that they wouldn’t need types because they already have tests. Some may question whether the benefit would really outweigh the TypeScript tax. Some may have had bad experience with earlier versions of TypeScript before. And there are many outdated opinion pieces everywhere.

But adopting TypeScript doesn’t have to be a big, all-or-none effort.

There are strategies for incrementally introducing pieces and bits of TypeScript into your JavaScript project, each little step immediately improving the developer experience, without having to install extra dependencies or make any changes to the build system.

This is what I discuss about in this talk. It also contains real-world examples which is kinda hard to convey just in text.

Topics discussed
  • How you may already be using TypeScript in your JavaScript project.
  • TypeScript the language, the compiler, and the language service.
  • Using JSDoc to improve type inference, code completions, and IntelliSense.
  • Configuring jsconfig.json for improved code actions and automatic refactoring.
  • Using // @ts-check to type-check JavaScript files (with examples on dealing with a few type-checking errors).
  • Enabling checkJs to type-check JavaScript files project-wide.
  • Creating a .d.ts file next to a JavaScript file to keep the .js file unmodified.
  • Creating a global .d.ts file to declare modules and global variables.
  • Discussion on strategies for improving developer productivity, improving code documentation, and reducing chance of runtime errors.

Note: The talk is in Thai language but I added English captions, and all slides are in English.

Hope you find it useful, and thanks for watching! Also, please consider subscribing to my YouTube channel for more content.

Discussion (0)