--- id: wiki-2026-0508-excess-property-checking title: Excess Property Checking category: 10_Wiki/Topics status: verified canonical_id: self aliases: [TypeScript Excess Property, Strict Object Literal] duplicate_of: none source_trust_level: A confidence_score: 0.9 verification_status: applied tags: [typescript, type-system, structural-typing] raw_sources: [] last_reinforced: 2026-05-10 github_commit: pending tech_stack: language: typescript framework: none --- # Excess Property Checking ## 매 한 줄 > **"매 fresh object literal 의 only 의 strict property check"**. TypeScript 매 structural typing 매 normally 의 extra properties 의 allow, 매 but 의 fresh object literal 의 directly 의 typed slot 의 assign 시 매 extra properties 의 error 의 raise. Typo 방지 + intent clarity 의 design choice. ## 매 핵심 ### 매 Why exists - 매 structural typing 매 `{a:1, b:2}` 의 `{a:number}` 의 assignable. - 매 그러나 매 literal 매 typo 의 high risk — `{ colour: 'red' }` 매 `{ color?: string }` 매 silent ignore. - 매 TS 매 fresh literal 의 special-case — 매 `Object literal may only specify known properties` 의 error. ### 매 Fresh-ness 매 lost - 매 variable 의 assign 시 매 widened — `const x = { extra: 1 }; fn(x)` 매 ok. - 매 spread 매 fresh-ness 의 keep (TS 4.0+). - 매 type assertion `as T` 매 bypass. - 매 index signature `[k: string]: ...` 매 disable. ### 매 응용 1. React props typo detection. 2. Config object validation. 3. API request body shape enforcement. 4. Discriminated union narrowing aid. ## 💻 패턴 ### Basic excess error ```typescript interface Point { x: number; y: number } const p: Point = { x: 1, y: 2, z: 3 }; // ^^^^ Object literal may only specify known properties ``` ### Bypass via intermediate variable ```typescript const tmp = { x: 1, y: 2, z: 3 }; const p: Point = tmp; // OK — fresh-ness lost // Use this only when extra properties are intentional ``` ### Index signature 의 opt-out ```typescript interface Config { name: string; [key: string]: unknown; // 매 extra props 의 allow } const c: Config = { name: 'x', debug: true, port: 3000 }; // OK ``` ### React props 의 typo guard ```typescript type ButtonProps = { label: string; onClick: () => void }; function Button(props: ButtonProps) { /* ... */ }