Description #
TypeScript is a statically typed superset of JavaScript that compiles to plain JavaScript. It adds optional type annotations, interfaces, and powerful development tools like intelligent code completion and compile-time error checking, making it ideal for building large-scale web and enterprise applications.
History #
TypeScript was developed by Microsoft and first released in 2012. It was created to address the shortcomings of JavaScript when developing large applications, particularly the lack of type safety and tooling.
Key highlights:
- Built and maintained by Microsoft, with contributions from Google, Slack, and others
- TypeScript 2.0 (2016) added non-nullable types, control flow analysis
- TypeScript 4+ (2020βpresent) introduced variadic tuples, labeled tuples, and improved type inference
TypeScript has become the de facto standard for modern frontend development in frameworks like Angular, React, Vue, and Next.js.
Hello World Code #
let message: string = "Hello, World!";
console.log(message);
How to Run #
Install TypeScript globally:
npm install -g typescript
Save the file as hello.ts
Compile it:
tsc hello.ts
Run the compiled JavaScript:
node hello.js
Key Concepts #
let message: string
β defines a variable with a type- Static typing β catches type errors during compilation
- Compiles to standard JavaScript
- Supports ES6+ features and beyond
- Integrates with JavaScript codebases
- Type inference and type aliases
- Interface and type declarations
- Powerful tooling via VS Code integration
- Used with React, Angular, Vue, Node.js
- Great for large-scale and team-based development
Try It Online #
π TypeScript Playground (Official)
π Replit β TypeScript
π StackBlitz
Fun Facts #
- TypeScript is backed by Microsoft and used to build Visual Studio Code
- You can convert any JavaScript file to TypeScript with
.ts
and gradual typing - Angular is written entirely in TypeScript
- TypeScript helps teams catch bugs before runtime
- Despite being a superset, it compiles down to vanilla JavaScript