TypeScript Reference ยท Error Codes Worth Knowing
TypeScript error TS2353: object literal may only specify known properties
TS2353 is the excess property check: a fresh object literal has a property the target type does not declare. Learn why it exists and how to fix or bypass it safely.
TS2353 reads Object literal may only specify known properties, and 'z' does not exist in type 'Point'. It is the excess property check. When you write an object literal directly where a type is expected (an assignment, an argument, a return value), every property must exist in the target type. The common causes are typos (colour for color), options that were renamed, and data that belongs to a different type.
The check applies only to fresh object literals. The same object stored in a variable first and then passed along is accepted, because the structural rule only requires the needed properties to be present.
interface Point { x: number; y: number } const p: Point = { x: 1, y: 2, z: 3 }; // error TS2353
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.
Syntax
What counts as "known" depends on the target type:
| Target | Excess property rule |
|---|---|
| Interface or object type | Only declared properties allowed. |
| Union of object types | A property must exist in at least one member (for discriminated unions, in the selected member). |
| Type with an index signature | Any property of a compatible type is allowed. |
object, {} or unknown |
No properties are checked. |
| Intersection | Properties from any part are known. |
Usage notes
- Why it exists. Misspelt optional properties are silently ignored in JavaScript. Without this check,
{ colour: "red" }passed to a function expecting{ color?: string }would type-check yet do nothing. - Weak types. If all target properties are optional and your object shares none of them, TS2559 ("has no properties in common") applies instead.
- Fixing in the right place. Ask whether the type is missing a property, or the object has a stray one. Do not reflexively widen the type.
- Intermediate variable works but hides the typo check; prefer fixing the property, or use
satisfiesto keep literal checking while preserving the narrower type. - Assertion
{...} as Pointbypasses the check; avoid it for this purpose. - Nested objects are checked recursively, so a typo deep inside a literal is reported on the inner property.