---
id: wiki-2026-0508-typescript
title: TypeScript
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [TS, Typed JavaScript]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [language, typescript, javascript, types]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
  language: typescript
  framework: tsc-bun-deno
---

# TypeScript

## 매 한 줄
> **"매 JavaScript 의 superset + structural type system + erasure compile"**. Microsoft 의 Anders Hejlsberg 의 lead, 2012 release. 매 2026 의 v5.6 (Q1) — TC39 Stage 3 type-annotation proposal 의 ECMAScript inclusion 의 progress, Bun/Deno 의 native runtime 의 TS 의 zero-config execution 의 standard.

## 매 핵심

### 매 Type System
- **Structural** (duck typing 의 formalize), nominal X.
- **Gradual** — `any` / `unknown` escape hatch.
- **Erasure** — runtime 의 zero overhead 의 strip.
- **Inference** — 매 explicit annotation 의 minimize.

### 매 Key Constructs
- `interface` / `type` — 매 interchangeable mostly.
- `as const` — literal narrowing.
- Generics — `<T>`, `extends`, `infer`.
- Mapped types — `{[K in keyof T]: ...}`.
- Conditional types — `T extends U ? X : Y`.
- Template literal types — `` `prefix-${T}` ``.

### 매 Modern (5.x) Features
- `const` type parameters (5.0).
- `satisfies` operator (4.9).
- Decorators stage 3 (5.0).
- Stricter `unknown` in catch (4.4 default).
- `using` declarations (5.2, ES2026 explicit resource management).

### 매 응용
1. Frontend — React / Vue / Svelte 의 default.
2. Backend — Node, Bun, Deno, Cloudflare Workers.
3. Tooling — eslint plugins, build scripts.
4. Schema — Zod / Valibot / ArkType 의 runtime validation.

## 💻 패턴

### Discriminated union
```typescript
type Shape =
  | { kind: "circle"; radius: number }
  | { kind: "square"; side: number };

function area(s: Shape): number {
  switch (s.kind) {
    case "circle": return Math.PI * s.radius ** 2;
    case "square": return s.side ** 2;
  }
}
```

### `satisfies` for literal-narrow + type-check
```typescript
const palette = {
  red: [255, 0, 0],
  green: "#00ff00",
} satisfies Record<string, [number, number, number] | string>;

palette.red[0];   // ok, number
palette.green.toUpperCase();  // ok, string
```

### Generic constraint + `infer`
```typescript
type ReturnType<T> = T extends (...args: any[]) => infer R ? R : never;

function fetchUser() { return { id: 1, name: "Alice" }; }
type User = ReturnType<typeof fetchUser>;  // {id: number, name: string}
```

### Branded types (nominal-ish)
```typescript
type Brand<T, B> = T & { __brand: B };
type UserId = Brand<string, "UserId">;
type OrderId = Brand<string, "OrderId">;

function getUser(id: UserId) { /* ... */ }
const oid = "ord_42" as OrderId;
// getUser(oid);  // Error: OrderId not assignable to UserId
```

### Zod schema → TS type
```typescript
import { z } from "zod";

const User = z.object({
  id: z.string().uuid(),
  email: z.string().email(),
  age: z.number().int().min(0),
});

type User = z.infer<typeof User>;

const parsed = User.parse(JSON.parse(body));  // runtime + type
```

### `using` (explicit resource cleanup, ES2026)
```typescript
class FileHandle implements Disposable {
  constructor(public path: string) { /* open */ }
  [Symbol.dispose]() { /* close */ }
}

function read() {
  using fh = new FileHandle("/tmp/data");
  // ... auto-close at scope exit
}
```

### Bun/Deno direct TS run
```bash
bun run script.ts            # native, no build
deno run --allow-net app.ts  # native + permissions
node --experimental-strip-types script.ts  # Node 22.6+
```

## 매 결정 기준
| 상황 | Approach |
|---|---|
| Library API | strict mode + `interface` |
| Internal app | `type` + Zod for boundaries |
| Discriminated state | `kind` field + switch |
| Runtime validation | Zod / Valibot / ArkType |
| Avoid `any` | `unknown` + narrow |
| Nominal IDs | branded types |

**기본값**: `tsconfig` strict, target ES2024, Bun/Deno runtime, Zod boundaries.

## 🔗 Graph
- 부모: [[JavaScript]]
- 변형: [[Flow]]
- 응용: [[React]] · [[Node-js]] · [[Bun]] · [[Deno]]
- Adjacent: [[Zod]] · [[ESLint]] · [[Vite]] · [[tsup]]

## 🤖 LLM 활용
**언제**: type 의 derive, generic constraint 의 design, error 의 explain.
**언제 X**: very recent TS feature (LLM cutoff 의 newer) — 매 official release notes 의 verify.

## ❌ 안티패턴
- **`any` 의 default**: 매 type system 의 disable.
- **`as` cast 의 over-use**: 매 runtime mismatch 의 hide.
- **`!` non-null assertion 의 abuse**: 매 narrow 의 effort 의 do.
- **`interface` vs `type` 의 endless debate**: 매 either 의 fine, consistency 의 important.
- **Decorator 의 prod 의 untested**: 매 stage 3 의 runtime 의 still 의 change.

## 🧪 검증 / 중복
- Verified (typescriptlang.org docs 5.6, TC39 type-annotations proposal).
- 신뢰도 A.

## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — type system + 5.x features + Bun/Deno runtime |
