Fixing TS2353 “Object literal may only specify known properties” in TypeScript
error TS2353: Object literal may only specify known properties, and 'age' does not exist in type 'User'. appears when you pass an object literal that has a property not in the type directly to an argument or variable of that type. The 'age' in the message is the extra property name. Either remove that property or add it to the type, and the error goes away.
This is how to read and fix the error when tsc reports an error after you pass a settings object to a function, or when VS Code shows a red squiggle under just one property inside an object. I reproduced this error in a test environment and included the message as-is. I confirmed that the error disappears after the fix, both with tsc and with the language server the editor uses.
The test environment was Ubuntu 24.04, Node.js 22.23.4, npm 10.9.9, and TypeScript 7.0.2. For the editor display, I did not use the editor application itself such as VS Code. Instead, I ran the TypeScript language server that editors use for diagnostics (tsc --lsp --stdio) directly. I did not test JSX attributes in React, or versions of TypeScript before 7.
- 1. The code that causes the error and its message
- 2. How to read the message
- 3. The language server reports the same diagnostic for the extra property
- 4. Running with the error still present silently ignores the extra property
- 5. Fix by removing the extra property
- 6. Fix by adding the property to the type if you need it
- 7. It also appears for variables with type annotations and return values
- 8. A typo in a property name also triggers it. When a suggestion is available, it becomes TS2561
- 9. Passing the object through a variable stops the error
- 10. If you want to accept properties with unknown names, use an index signature
The code that causes the error and its message
I ran npm init -y in an empty folder and added "type": "module" to package.json. I installed TypeScript 7.0.2 and used the tsconfig.json created by npx tsc --init as is (it includes "strict": true).
I wrote a User type with id and name, and a saveUser function that takes it. Then I passed an object with age, which is not in User. The file is src/user.ts.
type User = {
id: number;
name: string;
};
function saveUser(user: User) {
console.log(`保存: ${user.id} ${user.name}`);
}
saveUser({ id: 1, name: "たま", age: 3 });
Running npx tsc --noEmit printed the following line, and the exit code was 1.
$ npx tsc --noEmit
src/user.ts(10,31): error TS2353: Object literal may only specify known properties, and 'age' does not exist in type 'User'.
With --pretty, a squiggle appears under the extra property name (colors omitted).
src/user.ts:10:31 - error TS2353: Object literal may only specify known properties, and 'age' does not exist in type 'User'.
10 saveUser({ id: 1, name: "たま", age: 3 });
~~~
Found 1 error in src/user.ts:10
How to read the message
In plain English, the message says: an object literal can only contain properties defined in the type, and age is not in the User type.
Object literal: an object written inline with{ ... }(an object literal)'age': the extra property name that is not in the typetype 'User': the type required at the place where the object is passed; here, the type of thesaveUserargument
According to the section of the TypeScript Handbook that explains excess property checks, object literals get special, stricter checking when they are assigned to other variables or passed as arguments. If there is even one property that the target type does not have, you get an error. The Handbook takes the position that most of the errors this check catches are actual bugs.
The language server reports the same diagnostic for the extra property
I had the language server used by editors open the same src/user.ts. It returned one diagnostic with the same text as tsc (I omitted the server name line at the top).
diagnostics (1):
10:31-10:34 severity=1 source=ts code=2353 Object literal may only specify known properties, and 'age' does not exist in type 'User'.
The diagnostic range (the area the editor underlines) is 10:31-10:34, which covers only the three characters age on line 10. This display was formatted by my own check script: lines and columns are counted from 1, and the end position (column 34) does not include that character. severity=1 is the value that the Language Server Protocol specification uses for errors. The squiggle is drawn under the property name, not the whole object, so you can tell which property is the extra one from the position of the squiggle.
Running with the error still present silently ignores the extra property
Even with a type-check error, tsc still writes out JavaScript. When I removed --noEmit and wrote output to dist, the same TS2353 appeared and the exit code was 2, but dist/user.js was created. The noEmitOnError setting, which stops output when there are errors, defaults to false, as the TSConfig reference describes. With the default tsc --init settings, declaration files (.d.ts) and source maps are also output, so the command below specifies that only JavaScript should be written.
$ npx tsc --outDir dist --declaration false --declarationMap false --sourceMap false --rootDir src
src/user.ts(10,31): error TS2353: Object literal may only specify known properties, and 'age' does not exist in type 'User'.
$ node dist/user.js
保存: 1 たま
Running it did not produce an error, and since saveUser does not use age, that value was simply discarded.
Fix by removing the extra property
If saveUser does not use age, remove it from the caller. I changed line 10 as follows.
saveUser({ id: 1, name: "たま" });
npx tsc --noEmit finished with no output and exit code 0. The language server also returned 0 diagnostics.
Fix by adding the property to the type if you need it
If you want to receive and use age, change the type instead. Here I made it an optional property with ?, treating it as a value that is not always passed.
type User = {
id: number;
name: string;
age?: number;
};
function saveUser(user: User) {
console.log(`保存: ${user.id} ${user.name} ${user.age ?? "年齢なし"}`);
}
saveUser({ id: 1, name: "たま", age: 3 });
npx tsc --noEmit finished with exit code 0, and when I wrote the output and ran it, it printed 保存: 1 たま 3. Decide which fix to use based on whether the type should accept that property. The Handbook also recommends changing the type definition when passing an extra property is actually intended.
It also appears for variables with type annotations and return values
TS2353 is not limited to function arguments. It also appears when you put an object literal into a variable with a type annotation. In the examples below that use User, each file has the same User type on lines 1–4.
const user: User = { id: 1, name: "たま", age: 3 };
src/annotate.ts(6,41): error TS2353: Object literal may only specify known properties, and 'age' does not exist in type 'User'.
The same happens when a function with a declared return type writes an object literal in return.
function createUser(name: string): User {
return { id: Date.now(), name, createdAt: new Date() };
}
src/ret.ts(7,34): error TS2353: Object literal may only specify known properties, and 'createdAt' does not exist in type 'User'.
In both cases, removing the extra property (age, createdAt) or adding it to the User type fixes the error.
A typo in a property name also triggers it. When a suggestion is available, it becomes TS2561
If you misspell a property name that exists in the type, it is treated as a property not in the type. When I wrote nmae instead of name, I got TS2353.
const user: User = { id: 1, nmae: "たま" };
src/typo.ts(6,29): error TS2353: Object literal may only specify known properties, and 'nmae' does not exist in type 'User'.
Next is an options object that takes method and timeoutMs, where I wrote timeout when I meant timeoutMs.
type FetchOptions = {
method?: "GET" | "POST";
timeoutMs?: number;
};
function request(url: string, options: FetchOptions) {
console.log(url, options.method ?? "GET", options.timeoutMs ?? 5000);
}
request("https://example.com/api", { method: "POST", timeout: 3000 });
This one has the code TS2561, and the correct property name was suggested at the end. The language server's diagnostic had the same text, with the range 10:54-10:61, which covers the seven characters of timeout.
src/options.ts(10,54): error TS2561: Object literal may only specify known properties, but 'timeout' does not exist in type 'FetchOptions'. Did you mean to write 'timeoutMs'?
When I changed it to timeoutMs: 3000 as the suggestion said, the error disappeared, and the output was https://example.com/api POST 3000. The nmae example did not get a suggestion, so when there is no suggestion, compare the property names one by one against the type definition.
Passing the object through a variable stops the error
With the same object, if you put it in a variable first and then pass the variable, TS2353 does not appear.
const input = { id: 1, name: "たま", age: 3 };
saveUser(input);
npx tsc --noEmit exited with code 0. The Handbook also states that an object assigned to a separate variable does not get the excess property check.
This is not a recommended way to clear the error. Trying it with the typo example makes the problem clear.
const opts = { method: "POST" as const, timeout: 3000 };
request("https://example.com/api", opts);
Type checking passes, but at runtime the output was https://example.com/api POST 5000. timeout: 3000 is not read, and the default 5000 is used. A mistake that TS2561 would catch when written directly becomes invisible just by going through a variable.
Adding a type assertion such as as User also removes TS2353 ({ id: 1, name: "たま", age: 3 } as User exited with code 0). The Handbook presents this as the simplest way to avoid the check, but extra properties and typos then pass through without any error.
If you want to accept properties with unknown names, use an index signature
Sometimes you do want to intentionally accept properties that are not listed in the type. As described in the Handbook's section on index signatures, when you cannot decide property names in advance, you can make the type accept any name with a declaration such as [key: string]: unknown;.
type FetchOptions = {
method?: "GET" | "POST";
timeoutMs?: number;
[key: string]: unknown;
};
With this type, passing { method: "POST", timeout: 3000 } directly did not produce an error from tsc. However, the output was https://example.com/api POST 5000, and the misspelled timeout was still not read. Add an index signature only to types that truly need to accept and use properties with arbitrary names. The type without one is the one that catches typos.



