TypeScript error

TS2353: An object literal has a property its type does not know

  • Error TS2353
  • Tested with TypeScript 5.9

error TS2353: Object literal may only specify known properties, and 'hostName' does not exist in type ... is reported when you write an object literal straight into a typed place (a typed variable, a parameter, a return value) and one of its properties is not part of the type. The checker treats the extra property as a probable typo.

This check, which the handbook calls excess property checking, only applies to object literals written in place. The same object stored in a variable first and passed later is not checked for extra properties, because other code may legitimately add fields to it.

At a glance

CodeTS2353
MessageObject literal may only specify known properties, and '{0}' does not exist in type '{1}'.
TypeScript's categoryerror
Listed underTypes do not match
Turned on by No option: every checked file reports it
In .js files Reported when the file is checked: checkJs in jsconfig.json, or // @ts-check at the top of the file

The message is TypeScript's own text from its diagnostic messages file (Apache-2.0); {0} and {1} are filled in by tsc for each error.

What it looks like

server.js Error confirmed 5.9.3 TypeScript 5.9.3, run 21 October 2026: server.js(11,3): error TS2353: Object literal may only specify known properties, and 'hostName' does not exist in type '{ port: number; host?: string | undefined; }'. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. server.js(11,3): error TS2353: Object literal may only specify known properties, and 'hostName' does not exist in type '{ port: number; host?: string | undefined; }'. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. server.js(11,3): error TS2353: Object literal may only specify known properties, and 'hostName' does not exist in type '{ port: number; host?: string | undefined; }'. checked 21 October 2026
/**
 * @param {{ port: number, host?: string }} options
 */
export function listen(options) {
  return `http://${options.host ?? "localhost"}:${options.port}`;
}

listen({
  port: 3000,
  hostName: "0.0.0.0",error TS2353: Object literal may only specify known properties, and 'hostName' does not exist in type '{ port: number; host?: string | undefined; }'.
});
A misspelled option in an object literal.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": []
  },
  "include": ["*.js"]
}

What causes it

  • A property name in an object literal is misspelled or uses another library's name for the option (hostName for host).
  • The type is out of date: the option exists in the code but not in the @typedef or @param type.
  • The object deliberately carries extra keys (headers, metadata) and the type does not allow them.

How to fix it

Use the property name the type declares

Most of the time the fix is the spelling. The editor's completion list inside the object literal shows the names the type accepts.

server.js TypeScript 5.9.3 TypeScript 5.9.3, run 21 October 2026: No errors. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. No errors. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. No errors. checked 21 October 2026
/**
 * @param {{ port: number, host?: string }} options
 */
export function listen(options) {
  return `http://${options.host ?? "localhost"}:${options.port}`;
}

listen({
  port: 3000,
  host: "0.0.0.0",
});

/**
 * @param {{ port: number, [header: string]: string | number }} headers
 */
export function withHeaders(headers) {
  return Object.keys(headers);
}

withHeaders({ port: 3000, "x-request-id": "abc123" });
The option spelled as the type says, and a type that allows extra keys.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": []
  },
  "include": ["*.js"]
}

Add the property to the type, or allow extra keys

If the property is real, add it to the @typedef or the @param type. If the object is meant to hold any number of named values, give the type an index signature, as the withHeaders function in the fixed example does: { port: number, [header: string]: string | number }.

Gotchas

  • Passing a variable instead of a literal skips the check, so const options = { hostName: "x" }; listen(options) reports the missing port but not the extra hostName. Writing options inline is the safer habit.
  • A cast such as /** @type {Options} */ ({ ... }) also skips the excess check, which hides typos the same way.

Questions

Why is an extra property an error at all? JavaScript ignores it.

It is ignored at run time, which is exactly the problem: a misspelled option silently does nothing. Reporting it is the checker's way of catching the typo where it is written.

Sources

Last reviewed 20 October 2026.