# Typescript

> Typed JavaScript.

- Skill: `dhaupin/typescript` (Agent Skill)
- Install (CLI): `npx skillmds@latest add dhaupin/typescript`
- Raw SKILL.md: https://api.skillmd.com/api/skills/dhaupin/typescript/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- License: MIT
- Author: dhaupin (https://skillmd.com/u/dhaupin)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/dhaupin/typescript

---


# TypeScript

> Typed JavaScript.

---

## When To Use

- Type safety needed
- Large codebases
- Modern JS projects

---

## What To Do

### 1. Types

```typescript
interface User {
  id: number
  name: string
  email?: string  // optional
}

function getUser(id: number): User {
  return { id, name: 'User' }
}
```

### 2. Generics

```typescript
function first<T>(arr: T[]): T {
  return arr[0]
}
```

### 3. Compile

```bash
npx tsc --init
npx tsc
npx tsc --watch
```

### 4. Config

```json
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "commonjs",
    "strict": true
  }
}
```

---

**Role**: TypeScript Developer  
**Input**: .ts files  
**Output**: .js files

> Typed JS.
