TypeScript compilation performance best practices

Click for: original source

There are easy ways to configure TypeScript to ensure faster compilations and editing experiences. The earlier that these practices can be adopted, the better. By Daniel Rosenwasser.

Beyond best-practices, there are some common techniques for investigating slow compilations/editing experiences, some common fixes, and some common ways of helping the TypeScript team investigate the issues as a last resort.

The main parts of this guide:

  • Writing easy-to-compile code
  • Using project references
  • Configuring tsconfig.json or jsconfig.json
  • Configuring other build tools
  • Investigating issues
  • Common issues

TypeScript compilation is often performed with other build tools in mind - especially when writing web apps that might involve a bundler. While we can only make suggestions for a few build tools, ideally these techniques can be generalized.

Perceived editing performance is frequently impacted by a number of things, and the only thing within the TypeScript team’s control is the performance of the JavaScript/TypeScript language service, as well as the integration between that language service and certain editors (i.e. Visual Studio, Visual Studio Code, Visual Studio for Mac, and Sublime Text). Ensure that all 3rd-party plugins are turned off in your editor to determine whether there is an issue with TypeScript itself. Good read!

[Read More]

Tags nodejs javascript app-development web-development programming