Appearance
TypeScript
TypeScript is a strongly typed programming language that builds on JavaScript by adding static type definitions. Developed and maintained by Microsoft, TypeScript compiles to plain JavaScript and runs anywhere JavaScript runs: in a browser, on Node.js, or in any other JavaScript runtime.
Fun Fact
TypeScript does not uphold the semVer standard with their version numbering.
What is TypeScript?
TypeScript extends JavaScript by adding type syntax to the language. This allows developers to:
- Catch errors early during development rather than at runtime
- Improve code quality through better tooling, refactoring, and IntelliSense
- Enable better collaboration in teams by making code more self-documenting
- Scale applications more effectively with confidence in large codebases
Key Benefits
- Static Type Checking: Identify potential bugs before your code runs
- Enhanced IDE Support: Better autocomplete, navigation, and refactoring
- Modern JavaScript Features: Use the latest ECMAScript features with confidence
- Gradual Adoption: Add types incrementally to existing JavaScript projects
- Rich Ecosystem: Leverage type definitions for thousands of JavaScript libraries
How TypeScript Works
TypeScript code is written in .ts
(or <script lang="ts">
in vue) files and compiled to JavaScript using the TypeScript compiler (tsc
). The compilation process removes all type annotations, producing clean, readable JavaScript that runs everywhere.
typescript
// TypeScript
function greet(name: string): string {
return `Hello, ${name}!`;
}
// Compiled JavaScript
function greet(name) {
return `Hello, ${name}!`;
}