![]() |
TypeScript is a superset of JavaScript, which means that:
Any valid
.js
file is also a valid.ts
file (at least in theory).You can start writing TypeScript code by simply renaming a
.js
file in.ts
, and the code will continue to work.
But the strong point lies in the type system.
Static typing, optional but powerful
Unlike JavaScript, which is dynamic, in TypeScript you can declare the types of variables, parameters, and function returns.
Example:
let name: string = "Mike";
let age: number = 30;
let active: boolean = true;
let name = "Mike"; // TypeScript understands that it is a string
Compilation: from TS to JS
TypeScript does not run directly in the browser or on Node.js.
First, it is compiled into pure JavaScript, via the command:
tsc nomefile.ts
.js
file, removing all types and annotations. Example:function greeting(name: string): string {
return `Hello, ${name}`;
}
After compiling:
function greeting(name) {
return "Hello, " + name;
}
The generated code is fully compatible with any JavaScript environment.
TypeScript does not perform runtime checks; it is only needed during development and compilation. Types disappear after the build.
Tooling: TypeScript’s other superpower
One of the real benefits of TypeScript is how much it improves the development experience:
The editor (VSCode, WebStorm, etc.) can show you errors in real time
You can use IntelliSense to see the methods available on a variable
Refactoring (renaming variables, moving functions, etc.) is much safer
You can explore third-party libraries without having to read all the documentation
Example:
interface User {
name: string;
age: number;
}
const mike: User = {
name: "Mike",
age: 30,
};
mike.name.toUpperCase(); // with IntelliSense
TypeScript ≠ a different language
It’s easy to think of TypeScript as just another language. In reality, it’s a framework that helps you write better JavaScript.
Here's what doesn't change:
The execution rules are those of JS
The basic syntax is the same
You can use Web API, DOM, fetch, etc.
Here's what change:
You have tools to handle complex code with more confidence
You can define clear contracts between pieces of code
You can anticipate problems before they happen
But if types don’t exist at runtime… why use them?
Good question. Here's why it still makes sense:
Mistakes avoided during development
Augmented Intelligence of the IDE
Implicit documentation for you and your team
Checks on APIs, external libraries, complex structures
In short: write more robust and maintainable code.
In summary
TypeScript is a script-assisted transformation of your JavaScript:
It does not change how the browser or Node executes the code.
But it profoundly changes the way you and your editor understand that code.
It forces you (in a good way) to be more explicit, to think better about what you're doing, and protects you from many classic mistakes.
Follow me #techelopment
Official site: www.techelopment.it
facebook: Techelopment
instagram: @techelopment
X: techelopment
Bluesky: @techelopment
telegram: @techelopment_channel
whatsapp: Techelopment
youtube: @techelopment