Read Anthropic’s case study about Graphite Reviewer

TypeScript versioning

Kenny DuMez
Kenny DuMez
Graphite software engineer

TypeScript, developed by Microsoft, is a strongly typed programming language that builds on top of JavaScript. It offers optional static typing, classes, and interfaces, among other features that allow for more maintainable, safer code.

In this guide, we will explore aspects of TypeScript versioning, including how to check your TypeScript version, manage compatibility, and keep up with the latest updates.

TypeScript follows semantic versioning (semver), which is a widely adopted versioning scheme in software development. Semantic versioning is structured as MAJOR.MINOR.PATCH. Here’s what each segment represents:

  • MAJOR version is incremented when there are incompatible, breaking API changes.
  • MINOR version is incremented when functionality is added in a backward-compatible manner.
  • PATCH version is incremented when backward-compatible bug fixes are introduced.

This structure helps developers understand the potential impact of updating the TypeScript version in their projects.

To check the version of TypeScript installed on your system, you can run the following command in your terminal:

Terminal
tsc --version

This command invokes the TypeScript compiler (tsc) with the --version flag, which outputs the version of TypeScript currently installed.

If you’re working within a specific project, the TypeScript version used is usually specified in the project's package.json file under the devDependencies or dependencies section. You can check this file to see the exact version your project relies on. Additionally, you can run the following command in the root of your project to see what version of TypeScript is resolved according to your package manager's lock file:

Terminal
npx tsc --version

Using npx ensures you are executing the TypeScript compiler that is installed in your project's local node_modules directory, rather than any globally installed compiler.

Managing multiple versions of TypeScript can be important, especially when working on various projects or when different projects depend on different TypeScript versions. Node Version Manager (NVM) for Node.js does not directly handle TypeScript versions, but you can manage TypeScript versions by using npm or yarn to install specific versions locally within projects or globally on your machine.

For example, to install a specific version of TypeScript globally, you can use:

Terminal
npm install -g typescript@3.9.5

To install locally within a project:

Terminal
npm install --save-dev typescript@3.9.5

For more info, see this guide on installing TypeScript.

When dealing with multiple TypeScript projects or integrating with third-party libraries, it's important to consider version compatibility. Not all libraries are always updated to be compatible with the newest TypeScript releases. Libraries often list their required TypeScript version in their documentation or package.json file.

To manage compatibility issues, you may need to adjust your TypeScript version or use tools like @types packages to provide compatible type definitions.

To stay informed about the latest TypeScript versions, you can follow the official TypeScript website and the TypeScript GitHub repository. These sources provide release notes, documentation updates, and information about breaking changes and new features.

To update TypeScript to the latest version, you can use npm or yarn:

Terminal
npm install -g typescript@latest

For local project updates:

Terminal
npm install --save-dev typescript@latest

For more information on TypeScript versioning see the official TypeScript documentation.

Graphite
Git stacked on GitHub

Stacked pull requests are easier to read, easier to write, and easier to manage.
Teams that stack ship better software, faster.

Or install our CLI.
Product Screenshot 1
Product Screenshot 2