---
id: wiki-2026-0508-약한-타입-검사-weak-type-detection
title: 약한 타입 검사 (Weak Type Detection)
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [Weak Type Detection, TypeScript Weak Types, Excess Property Check]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [typescript, types, type-safety]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
  language: typescript
  framework: typescript-5
---

# 약한 타입 검사 (Weak Type Detection)

## 매 한 줄
> **"매 weak type 은 매 모든 property 가 매 optional 인 type → 매 TypeScript 가 매 어떤 object 든 매 assignable 로 보아 매 typo 매 silently"**. TS 2.4 (2017) 부터 매 specific weak-type assignment check 추가. 매 2026 modern TS 5.7 은 매 strict + exactOptionalPropertyTypes + verbatimModuleSyntax 로 매 default-strict.

## 매 핵심

### 매 weak type 정의
- 매 모든 property 가 매 `?:` (optional).
- 예: `interface Opts { timeout?: number; retry?: number; }`.

### 매 detection rule
- 매 source object 가 매 weak type target 의 매 어떤 property 와도 매 overlap 하지 않으면 → 매 error.
- 매 typo (e.g. `tiemout` instead of `timeout`) → 매 catch.

### 매 응용
1. 매 config object 매 typo 방지.
2. 매 partial type 의 매 안전한 사용.
3. 매 React props 의 매 narrow 검사.

## 💻 패턴

### Basic weak-type error
```typescript
interface Options {
  timeout?: number;
  retry?: number;
}

function call(opts: Options) { /*...*/ }

// ✗ Error: Type '{ tiemout: number; }' has no properties in common with type 'Options'.
call({ tiemout: 30 });

// ✓
call({ timeout: 30 });
```

### Excess property check (related)
```typescript
// Object literal — excess properties checked
call({ timeout: 30, foo: 1 }); // ✗ Error: 'foo' does not exist

// Variable — only weak-type rule applies
const o = { timeout: 30, foo: 1 };
call(o); // ✓ (excess check skipped, but weak-type still checks overlap)
```

### exactOptionalPropertyTypes (TS 4.4+, default in 2026 setups)
```json
{ "compilerOptions": { "exactOptionalPropertyTypes": true } }
```

```typescript
interface User { name: string; nickname?: string; }
const u: User = { name: "kim", nickname: undefined }; // ✗ Error
const u2: User = { name: "kim" };                      // ✓
```

### Branded type to avoid weak-type ambiguity
```typescript
type UserId = string & { readonly __brand: "UserId" };
type OrderId = string & { readonly __brand: "OrderId" };

function getUser(id: UserId) { /*...*/ }
const oid = "ord_1" as OrderId;
getUser(oid); // ✗ Error
```

### Required<> to disable weak detection
```typescript
type StrictOptions = Required<Options>;
function strictCall(opts: StrictOptions) { /*...*/ }
strictCall({ timeout: 30 }); // ✗ retry missing — clearer than weak type
```

### Const assertion for narrow inference
```typescript
const opts = { timeout: 30 } as const;
type T = typeof opts; // { readonly timeout: 30 }
```

## 매 결정 기준
| 상황 | Approach |
|---|---|
| 매 config object | 매 weak-type 의 명시적 인지 |
| 매 ID confusion | branded types |
| 매 truly partial input | `Partial<T>` + explicit narrow |
| 매 strict undefined handling | exactOptionalPropertyTypes |
| 매 enum-like literal | `as const` |

**기본값**: 매 `strict: true` + `exactOptionalPropertyTypes: true`.

## 🔗 Graph
- 부모: [[TypeScript]] · [[TypeScript 타입 시스템 (TypeScript Type System)|Type System]]
- 변형: [[Excess Property Check]] · [[Structural Typing]]
- 응용: [[Branded Types]]
- Adjacent: [[선언 파일 dts]]

## 🤖 LLM 활용
**언제**: 매 type error 의 매 explanation / 매 branded type design.
**언제 X**: 매 production code 의 매 mass refactor — 매 incremental.

## ❌ 안티패턴
- **All-optional config**: 매 weak type 의 typo 위험.
- **`any` escape**: 매 weak-type error 회피용 매 `any`.
- **Spreading external object**: 매 weak-type check 우회.
- **Disabling strict**: 매 entire codebase 의 매 type-safety 손실.

## 🧪 검증 / 중복
- Verified (TypeScript 2.4 release notes, TypeScript Handbook 2026, *Effective TypeScript 3e*).
- 신뢰도 A.

## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — weak-type / branded / exactOptional 패턴 추가 |
