excess-property-checking

Diagnose TypeScript excess property checking errors on object literals versus variables.

Updated Sep 5, 2026
One-click install
npx skills add https://github.com/pohlai88/afenda-xforge-v5 --skill excess-property-checking-pohlai88
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: excess-property-checking
Source: https://github.com/pohlai88/afenda-xforge-v5/tree/main/.agents/skills/excess-property-checking
Command: npx skills add https://github.com/pohlai88/afenda-xforge-v5 --skill excess-property-checking-pohlai88

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? TypeScript flags unknown properties on object literals but silently allows the same extra properties through intermediate variables, causing confusion about why identical code sometimes errors and sometimes passes. This Skill explains the distinction so you stop bypassing the check with type assertions and start catching real typos in property names. ## Core Features & Use Cases - Error Diagnosis: Explains why "Object literal may only specify known properties" appears for literals but disappears with intermediate variables or type assertions. - Typo Detection Guidance: Shows how excess property checking catches misspelled optional properties like darkmode instead of darkMode. - Weak Type Handling: Covers the special check for interfaces with only optional properties, which applies even through variables. - Use Case: You assign a config object to a typed variable and get an "unknown property" error, but the error vanishes when you use an intermediate variable. This Skill explains why and shows the correct fix instead of an unsafe as assertion. ## Quick Start Ask the AI to explain why my TypeScript object literal triggers an excess property error while the same value assigned through a variable does not.

Frequently Asked Questions about excess-property-checking

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does TypeScript say object literal may only specify known properties?

TypeScript applies excess property checking to object literals assigned to typed variables, flagging properties not in the target type. This catches typos like `darkmode` instead of `darkMode` that structural typing would otherwise allow silently.

How do I fix excess property checking errors in TypeScript?

Fix the underlying issue by correcting the property name typo or updating the type definition. If extra properties are intentional, add an index signature like `[key: string]: unknown` to the interface rather than using a type assertion.

Why does the excess property error disappear with an intermediate variable?

Excess property checking only applies to object literals, not variables. Assigning through an intermediate variable falls back to structural typing, which permits extra properties, so the error disappears but potential typos go undetected.

Does TypeScript type assertion bypass excess property checking?

Yes, using `as Type` bypasses excess property checking entirely, which hides bugs instead of fixing them. Prefer correcting the property name or extending the interface with an index signature when extra properties are legitimate.

What is a weak type in TypeScript and why does it error?

A weak type is an interface with only optional properties. TypeScript requires at least one property in common between the assigned value and the weak type, and this check applies even through intermediate variables, unlike regular excess property checking.