--- id: wiki-2026-0508-과잉-속성-체크-excess-property-checkin title: 과잉 속성 체크 (Excess Property Checking) category: 10_Wiki/Topics status: verified canonical_id: self aliases: [Excess Property Checking, EPC, TS Excess Property] duplicate_of: none source_trust_level: A confidence_score: 0.9 verification_status: applied tags: [typescript, type-system, structural-typing, epc] raw_sources: [] last_reinforced: 2026-05-10 github_commit: pending tech_stack: language: TypeScript framework: TS 5.x --- # 과잉 속성 체크 (Excess Property Checking) ## 매 한 줄 > **"매 object literal 을 직접 assign / pass 할 때만 발동하는 TS 의 추가 strictness rule"**. 매 structural typing 의 원칙적으론 OK 인 extra property 를 매 fresh object literal 에 한해 error 로 잡아 typo 방지. 매 변수 경유 시 자동 비활성화. ## 매 핵심 ### 매 작동 방식 - TS 의 **structural / duck typing** 은 매 extra property OK. - 그러나 매 **object literal 을 fresh 하게 assign 시** TS 는 추가로 surplus key 를 error 로 보고. - 매 변수에 한 번 alias 하면 fresh 신호가 사라져 EPC 우회. ### 매 발동 조건 - 매 object literal 의 직접 assignment / argument / return. - 매 contextual type 이 존재. - 매 변수 경유, type assertion (`as`), spread 시 비활성화. ### 매 응용 1. Component prop typo 방지 (React). 2. API request body 의 surplus field 차단. 3. Config object 의 misnamed key 발견. ## 💻 패턴 ### 매 EPC 발동 (error) ```typescript interface User { name: string; age: number } const u: User = { name: "Lee", age: 30, emial: "x" }; // ^^^^^ 매 EPC: 'emial' does not exist on User ``` ### 매 변수 경유 우회 (error 사라짐) ```typescript const raw = { name: "Lee", age: 30, emial: "x" }; const u: User = raw; // ✅ OK — fresh 아니라 EPC 비활성 // 매 structural compatibility 만 본다 (User 의 모든 prop 충족 → OK) ``` ### 매 함수 인자 EPC ```typescript function greet(u: User) { console.log(u.name); } greet({ name: "A", age: 1, extra: 1 }); // ❌ EPC error const x = { name: "A", age: 1, extra: 1 }; greet(x); // ✅ OK ``` ### 매 index signature 의 escape hatch ```typescript interface Loose { name: string; [key: string]: unknown; } const l: Loose = { name: "A", whatever: 123, deep: { x: 1 } }; // ✅ OK ``` ### 매 union type 의 EPC quirk ```typescript type A = { kind: "a"; a: number }; type B = { kind: "b"; b: number }; const x: A | B = { kind: "a", a: 1, b: 2 }; // ❌ EPC: 'b' is not in A; not in B 의 fresh form // 매 변수 경유 시 통과 — 의도치 않은 leakage 가능 ``` ### 매 의도적 우회 (type assertion — 위험) ```typescript const u: User = { name: "A", age: 1, emial: "x" } as User; // ⚠ 매 작동하지만 매 typo 의 silent — 매 강력히 X ``` ### 매 React component prop typo 방지 ```typescript type ButtonProps = { label: string; onClick: () => void }; const Button = (p: ButtonProps) => ;