Live streamJoin us for "State of code review 2024" on July 18thRegister today

What is TypeScript?

Kenny DuMez
Kenny DuMez
Graphite software engineer

TypeScript, developed and maintained by Microsoft, is a programming language which adds static typing to JavaScript to provide safer, more maintainable code. It is a superset of JavaScript, meaning that any valid JavaScript code is also valid TypeScript code, but TypeScript allows for optional typing, interfaces, classes, and other features that JavaScript does not natively support.

By compiling down to plain JavaScript, TypeScript ensures compatibility with all JavaScript engines, making it a popular choice for developers looking to enhance code reliability and maintainability without sacrificing on compatibility.

A TypeScript file is a text file containing TypeScript code with a .ts extension (or .tsx if JSX is used). These files are written using TypeScript syntax and are then compiled into JavaScript files by the TypeScript compiler, which are then used in production.

TypeScript is used primarily to develop large-scale JavaScript applications. Its static typing system helps catch errors early in the development process, making the codebase easier to manage and refactor. Here are some common use cases:

  • Enterprise-level applications: Large applications benefit from TypeScript’s type system, which enhances code quality and maintainability.
  • Angular framework: TypeScript is the primary language recommended by Angular, a popular front-end development framework.
  • React and Vue: Many React and Vue developers opt for TypeScript to improve the reliability and scalability of their applications.
  • Node.js Development: TypeScript is also increasingly popular for backend development with Node.js due to its robust typing and object-oriented features.

While JavaScript and TypeScript share many similarities, there are several key differences:

  • Type system: JavaScript is dynamically typed, meaning the type of a variable is checked during runtime. TypeScript introduces static typing, where the type of a variable is checked during compile time.
  • Class features: TypeScript supports modern JavaScript features and adds additional features like enums and interfaces, which are not available in JavaScript.
  • Tooling: TypeScript provides superior tooling at any scale with autocompletion, type checking, and other features that help developers manage large codebases efficiently.
  • Error checking: TypeScript compiler performs advanced error checking based on types. This catches common errors like misspelling property names or incorrect data types, which can be overlooked in JavaScript until runtime.
  • Modules: Both languages support modules, but TypeScript provides stronger enforcement of type checks and object shapes across modules.

To start using TypeScript, you will need to install it and configure a basic project:

  1. Installation: Install TypeScript globally via npm (Node Package Manager):

    npm install -g typescript
  2. Creating a TypeScript file: Create a new file hello.ts:

    function greet(person: string): string {
    return 'Hello, ' + person
    let user = 'Jane User'
  3. Compiling TypeScript: Compile the TypeScript file to JavaScript using the TypeScript compiler:

    tsc hello.ts

    This command creates a hello.js file, which can be run in any JavaScript environment.

  4. Running JavaScript: You can run the generated JavaScript file using Node.js:

    node hello.js

For more detailed instructions see this guide on installing TypeScript.

Stay unblocked. Ship faster.
Experience the new developer workflow - create, review, and merge code continuously. Get started with one command.
Get started

Give your PR workflow
an upgrade today

Stack easier | Ship smaller | Review quicker

Or install our CLI.
Product Screenshot 1
Product Screenshot 2