How to Check TypeScript Version?

I’ve been working with TypeScript for years, and one of the first things I do when jumping into a new project is check the version.

It sounds simple, but knowing exactly which version you are running can save you hours of debugging weird type errors.

In this tutorial, I will show you exactly how to check your TypeScript version using four different methods I use in my daily workflow.

Why Knowing Your TypeScript Version is Important

This might look silly, but you, as a TypeScript developer, should know the version of the TypeScript you are using. Here are a few important reasons:

  • Compatibility: Certain features or syntax may only be available in specific versions.
  • Debugging: Identifying version-related issues can save time during debugging.
  • Upgrading: Ensuring compatibility with other dependencies when upgrading.

Now, let me show you some methods to check the version of TypeScript.

Method 1: Check TypeScript Version via Command Line

The simplest way to check your TypeScript version is through the command line. Open your terminal or command prompt and type the following command:

tsc -v

This command will display the currently installed TypeScript version. For example:

$ tsc -v
Version 5.2.2

Here is the screenshot for your reference; I executed the above command in my local system.

check typescript version

Method 2: Check the TypeScript Version in package.json

If you’re working on a project, the TypeScript version is often specified in the package.json file. Open the file ‘package.json’ and look for the devDependencies section. You should see an entry like this:

"devDependencies": {
  "typescript": "^4.5.2"
}

This indicates that the project is using TypeScript version 4.5.2.

Method 3: Use npm to Check TypeScript Version

You can also use npm to check the TypeScript version installed in your project. Run the following command in your terminal:

npm list typescript

This command will list the TypeScript version along with other dependencies. For example:

$ npm list typescript
project-name@1.0.0 /path/to/project
└── typescript@4.5.2

Method 4: Check the TypeScript Version in Visual Studio Code

If you’re using Visual Studio Code, you can easily check the TypeScript version by opening the command palette (Ctrl+Shift+P) and typing TypeScript: Select TypeScript Version. This will show the currently active TypeScript version and allow you to switch between versions if multiple are installed.

You can even see the TypeScript version in VS Code from the UI. In the right corner below, hover on TypeScript; you can see it will display the TypeScript version, as in the screenshot below.

Python Hello World Program

Method 5: Use Yarn to Check TypeScript Version

Here is the last method to check the TypeScript version.

For those using Yarn, you can check the TypeScript version by running:

yarn list --pattern typescript

This command will list all versions of TypeScript installed in your project. For example:

$ yarn list --pattern typescript
yarn list v1.22.10
├─ typescript@4.5.2

Conclusion

It is important to know how to check your TypeScript version to maintain compatibility and ensure your development environment is up-to-date. You can check the version of TypeScript using different methods, such as the command line, package.json, npm, Visual Studio Code, or Yarn.

You may also like:

51 Python Programs

51 PYTHON PROGRAMS PDF FREE

Download a FREE PDF (112 Pages) Containing 51 Useful Python Programs.

pyython developer roadmap

Aspiring to be a Python developer?

Download a FREE PDF on how to become a Python developer.

Let’s be friends

Be the first to know about sales and special discounts.