typescript
TypeScript is a strongly typed programming language that builds on JavaScript, adding static type definitions that help catch errors at compile time rather than…
Installation
npm install -D typescript
yarn add -D typescript
pnpm add -D typescript
Import
// TypeScript is a language, not typically imported
Quick Example
interface User {
id: number;
name: string;
email: string;
}
function greet(user: User): string {
return `Hello, ${user.name}!`;
}
const user: User = { id: 1, name: 'Alice', email: '[email protected]' };
console.log(greet(user));About typescript
TypeScript is a strongly typed programming language that builds on JavaScript, adding static type definitions that help catch errors at compile time rather than runtime. Developed by Microsoft, TypeScript compiles to clean, readable JavaScript that runs in any browser, on Node.js, or in any JavaScript runtime. The type system includes interfaces, generics, union and intersection types, conditional types, mapped types, template literal types, and type inference that minimizes the amount of explicit type annotations needed. TypeScript's Language Service powers the IDE experience in VS Code and other editors, providing autocompletion, inline error detection, refactoring tools, and go-to-definition navigation. The compiler (tsc) performs type checking and optionally transpiles TypeScript to JavaScript, though many projects use tsc only for type checking while delegating transpilation to faster tools like esbuild or SWC. TypeScript has become the default choice for new JavaScript projects, with adoption across all major frameworks and libraries. The declaration file system (.d.ts) provides type information for JavaScript libraries through DefinitelyTyped, the world's largest repository of type definitions.
Quick Facts
| Package | typescript |
| Category | Build Tool |
| Weekly Downloads | 45M+ |
| License | Apache-2.0 |
| Install | npm install -D typescript |
Related Packages
esbuild is an extremely fast JavaScript and TypeScript bundler and minifier written in Go that is 10…
SWC (Speedy Web Compiler) is a Rust-based JavaScript/TypeScript compiler that provides a drop-in rep…
Babel is the standard JavaScript compiler that transforms modern JavaScript and TypeScript syntax in…
tsx is a TypeScript execute tool that lets you run TypeScript files directly in Node.js without a co…
ts-node is a TypeScript execution engine and REPL for Node.js that transforms TypeScript to JavaScri…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.