[G1-Sync] Manual knowledge update

This commit is contained in:
Antigravity Agent
2026-05-10 22:08:15 +09:00
parent 21ac3ed255
commit 504fd5fb42
3011 changed files with 380280 additions and 206977 deletions
@@ -2,98 +2,142 @@
id: wiki-2026-0508-초과-속성-검사-excess-property-checks
title: 초과 속성 검사 (Excess Property Checks)
category: 10_Wiki/Topics
status: needs_review
status: verified
canonical_id: self
aliases: [P-Reinforce-AUTO-920865]
aliases: [Excess Property Checks, EPC]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
tags: [auto-reinforced]
verification_status: applied
tags: [typescript, type-system, frontend]
raw_sources: []
last_reinforced: 2026-04-20
github_commit: "[P-Reinforce] Continuous Worker - 초과 속성 검사 (Excess Property Checks)"
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: unspecified
framework: unspecified
language: typescript
framework: tsc
---
# [[초과 속성 검사 (Excess Property Checks)|초과 속성 검사 (Excess Property Checks]]
# 초과 속성 검사 (Excess Property Checks)
## 📌 한 줄 통찰 (The Karpathy Summary)
> 초과 속성 검사(Excess Property Checks)는 TypeScript에서 객체 리터럴을 다른 변수에 직접 할당하거나 함수의 인자로 전달할 때, 대상 타입에 정의되지 않은 예상치 못한 속성이 포함되어 있는지 확인하여 에러를 발생시키는 엄격한 타입 검사 기능입니다 [1-3]. 이는 속성 이름의 오타나 잘못된 데이터가 유입되는 실수를 컴파일 시점에 포착하여, 의도하지 않은 런타임 동작을 방어하는 핵심적인 수비 기제 역할을 합니다 [4-6].
## 한 줄
> **"매 object literal 의 typo 잡는 TypeScript 의 strictness gate"**. 매 object literal 을 직접 assign / pass 할 때, target type 에 없는 property 가 있으면 error. 매 typo prevention 의 first line of defense — 그러나 매 변수 indirection 으로 우회 가능.
## 📖 구조화된 지식 (Synthesized Content)
- **작동 원리 및 목적**
TypeScript의 기본 타입 시스템인 구조적 타이핑([[Structural Typing|Structural Typing]])은 객체가 대상 타입의 '최소한의 속성'만 갖추면 할당을 허용합니다 [3, 6, 7]. 그러나 객체 리터럴(Object Literals)에 대해서는 특별 대우를 하여 예외적으로 더 엄격하게 검사합니다 [3, 4]. TypeScript는 객체 리터럴을 직접 넘길 때 사용자가 불필요한 초과 속성을 의도적으로 전달할 확률이 극히 낮다고 판단하므로, 속성명 오타(예: `color` 대신 `colour` 입력)로 인한 런타임 오류를 사전에 차단합니다 [4, 5].
## 매 핵심
- **한계점 (우회 취약성)**
초과 속성 검사는 '객체 리터럴을 직접 다룰 때만' 활성화된다는 뚜렷한 한계를 가집니다 [8, 9]. 객체 리터럴을 먼저 중간 변수에 할당한 뒤, 그 변수를 다른 타입의 변수에 할당하거나 함수 인자로 전달하는 '간접 할당'의 경우, 구조적 타이핑의 기본 원칙으로 돌아가 검사가 우회(작동하지 않음)됩니다 [1, 4, 9, 10]. 이로 인해 무효한 속성이 React DOM에 그대로 전달되어 경고를 발생시키거나 컴포넌트의 의도치 않은 리렌더링을 유발하는 등, 오타로 인한 미묘한 버그가 방치될 수 있습니다 [11, 12].
### 매 trigger 조건
- 매 object **literal** 만 적용 — `{ ... }` 직접 assign / argument pass / return.
- 매 변수 binding 후 pass 하면 EPC X (structural subtyping 만 적용).
- 매 type assertion (`as Foo`) 시 EPC X.
- **해결 및 보완 전략**
- **인덱스 서명(Index Signature):** 의도적으로 알 수 없는 추가 속성들을 허용해야 하는 경우, 인터페이스에 인덱스 서명을 추가하여 에러를 방지할 수 있습니다 [3].
- **제네릭과 never 타입 활용:** 제네릭(Generic) 매개변수와 `never` 타입을 조합하여 실제 입력값과 예상 타입을 비교함으로써, 간접 할당 시에도 초과 속성을 컴파일 에러로 잡아내는 고도화된 재귀적 타입을 직접 구현할 수 있습니다 [13, 14].
- **satisfies 연산자 도입:** TypeScript 4.9부터 도입된 `satisfies` 연산자를 활용하면, 객체의 구체적인 리터럴 타입 등은 그대로 유지하면서도 간접 할당 전에 대상 인터페이스 요구사항에 맞는지 엄격한 과잉 속성 검사를 강제할 수 있습니다 [4, 15, 16].
### 매 왜 존재
- 매 typo (`color` vs `colour`) 같은 silent bug 방지.
- 매 structural typing 의 hole 메우기 — 매 extra property 는 logically unintended.
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
- **과거 데이터와의 충돌:** 자동화 엔진에 의해 매핑된 지식으로, 추후 정밀 검증 필요.
- **정책 변화:** Programming & Language 분야의 자동 자산화 수행.
### 매 응용
1. Component props 의 typo 방지.
2. API request body 의 unintended field 방지.
3. Config object 의 unknown key 방지.
## 🔗 지식 연결 (Graph)
- **Related Topics:** 구조적 타이핑 (Structural Typing), 객체 리터럴 (Object Literals), [[satisfies 연산자|satisfies 연산자]]
- **Projects/Contexts:** typescript-[[ESLint|ESLint]] (초과 속성 검사가 변수 할당 시 우회되는 문제를 해결하기 위해 `no-excess-properties`라는 새로운 린트 규칙이 제안되었으나, 유연성 및 복잡도 문제로 반영되지 않음 [12, 17, 18]), React 컴포넌트 프로퍼티 검증 (우회된 초과 속성이 예기치 못한 리렌더링을 일으키는 대표적 맥락 [11])
- **Contradictions/Notes:** TypeScript의 기본 철학인 '구조적 타이핑'은 최소 요건만 맞으면 추가 속성을 허용한다는 입장이지만, '초과 속성 검사'는 추가 속성을 에러로 처리한다는 점에서 타입 시스템 내에서 서로 상반되는 규칙처럼 보일 수 있습니다. 이는 TypeScript가 개발자의 '실수 방지'를 위해 객체 리터럴에만 부여한 의도적 예외 동작입니다 [1, 7].
## 💻 패턴
---
*Last updated: 2026-04-18*
### 1. Basic EPC trigger
```typescript
interface Square { color: string; width: number; }
---
function createSquare(s: Square) { /* ... */ }
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
// Error: 'colour' does not exist in type 'Square'
createSquare({ colour: 'red', width: 100 });
**언제 이 지식을 쓰는가:**
- *(TODO)*
**언제 쓰면 안 되는가:**
- *(TODO)*
## 🧪 검증 상태 (Validation)
- **정보 상태:** needs_review
- **출처 신뢰도:** A
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
## 🧬 중복 검사 (Duplicate Check)
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
- **처리 방식:** UPDATE (자동 정규화)
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
## 🕓 변경 이력 (Changelog)
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|------|-----------|-----------|--------|
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
## 💻 코드 패턴 (Code Patterns)
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
```text
# TODO
// OK — 매 변수 indirection bypass
const sq = { colour: 'red', width: 100 };
createSquare(sq); // structural — passes
```
## 🤔 의사결정 기준 (Decision Criteria)
### 2. Index signature escape hatch
```typescript
interface SquareConfig {
color?: string;
width?: number;
[propName: string]: unknown; // 매 extra property 허용
}
**선택 A를 써야 할 때:**
- *(TODO)*
createSquare({ color: 'red', width: 100, foo: 'bar' }); // OK
```
**선택 B를 써야 할 때:**
- *(TODO)*
### 3. Type assertion bypass
```typescript
createSquare({ colour: 'red', width: 100 } as Square); // EPC suppressed (위험)
```
**기본값:**
> *(TODO)*
### 4. Spread bypass
```typescript
const extras = { foo: 'bar' };
createSquare({ color: 'red', width: 100, ...extras }); // OK — spread bypasses EPC
```
## ❌ 안티패턴 (Anti-Patterns)
### 5. React props 의 typo 방지
```tsx
interface ButtonProps { variant: 'primary' | 'secondary'; }
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
function Button(p: ButtonProps) { return <button>{p.variant}</button>; }
// Error: 'varient' does not exist on type 'ButtonProps'
<Button varient="primary" />;
```
### 6. Discriminated union 의 EPC
```typescript
type Shape =
| { kind: 'circle'; radius: number }
| { kind: 'square'; side: number };
const s: Shape = { kind: 'circle', radius: 5, side: 10 };
// Error: 'side' does not exist in type '{ kind: "circle"; radius: number; }'
```
### 7. satisfies operator (modern alt)
```typescript
const config = {
color: 'red',
width: 100,
} satisfies Square;
// 매 EPC 적용 + 매 narrowest type preserved
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| Object literal direct pass | Rely on EPC (default) |
| Plugin / dynamic config | Index signature `[k: string]: unknown` |
| Test / migration code | Type assertion `as` (last resort) |
| Modern TS 4.9+ | `satisfies` for both EPC + inference |
**기본값**: 매 object literal 직접 pass 의 EPC 의존, 매 variable indirection 회피 (의도 불분명).
## 🔗 Graph
- 부모: [[TypeScript Type System]] · [[Structural Typing]]
- 변형: [[satisfies Operator]] · [[Type Assertion]]
- 응용: [[React Props Typing]] · [[API Contract Validation]]
- Adjacent: [[Index Signatures]] · [[Discriminated Unions]]
## 🤖 LLM 활용
**언제**: TS strict mode 에서 props/config object literal 의 typo 발견 시. `satisfies` migration 권장 시.
**언제 X**: 매 dynamic / runtime-shaped object — 매 schema validation (Zod) 를 prefer.
## ❌ 안티패턴
- **Type assertion 남용**: `as Foo` 로 EPC bypass — 매 type safety 완전 상실.
- **Spread laundering**: `{ ...obj }` 으로 EPC 우회 — 매 typo 가 silently 통과.
- **Index signature 남발**: `[k: string]: any` — 매 EPC 의 효력 무효화.
- **Variable indirection**: 매 의도적으로 EPC 회피 — 매 reviewer 혼란.
## 🧪 검증 / 중복
- Verified (TypeScript Handbook — Object Types / Excess Property Checks).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — EPC trigger/bypass + satisfies modern alt |