A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/typescript/how-typescript-compilation-works/ below:

How TypeScript Compilation Works? - GeeksforGeeks

How TypeScript Compilation Works?

Last Updated : 18 Mar, 2025

TypeScript is a superset of JavaScript that adds type safety to your code. It compiles into plain JavaScript, allowing it to run in any JavaScript environment.

The TypeScript compiler (tsc) checks the code for errors and then converts it into JavaScript. During this process, all TypeScript-specific features like type annotations are removed, leaving behind clean JavaScript code.

Let's understand how TypeScript compilation works:

Steps of TypeScript Compilation

The TypeScript compilation process transforms your TypeScript code into executable JavaScript. Here’s how it works step by step:

Example

Here we are going to see a TypeScript code snippet and its corresponding compiled JavaScript output. This will help you understand how TypeScript's type annotations and features are translated into standard JavaScript.

TypeScript Code:

JavaScript
let displayData = (
    id: number, 
    name: string, 
    field: string) : string => {
          return (id + " - " + name + " - " + field);
}

console.log(displayData(1 , "Aman", "CSE"));

Compiled JavaScript Code:

After compiling the TypeScript code, the resulting JavaScript code is:

JavaScript
var displayData = function (id, name, field) {
    return id + " - " + name + " - " + field;
};
console.log(displayData(1, "Aman", "CSE"));

Output:

1 - Aman - CSE
Basic Facts About TypeScript

Here are some basic facts about TypeScript:

TypeScript Compilation Flaws

While TypeScript offers significant advantages, it's important to be aware of its limitations, particularly concerning compilation:



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4