How to Fix TypeScript TS2551 “Did you mean” Property Name Errors
The TypeScript error error TS2551: Property 'emial' does not exist on type 'User'. Did you mean 'email'? appears when you misspell a property name. The Did you mean at the end of the message shows the closest name in the type. Changing your code to that name makes the error go away.
You often see this error when you use a property on a type you wrote for an API response, or when you call a DOM method such as document.getElementById. Your editor shows a red squiggle, or npm run build fails at the tsc step. However, the suggestion is not always correct. If the typo is in the type definition, the suggestion will be the wrong name.
The test environment was Ubuntu 24.04, Node.js 22.23.5, npm 10.9.9, and TypeScript 7.0.2. I also checked the editor quick fixes with the TypeScript 5.9.3 language service (tsserver). I did not check the screens of editors such as VS Code. I ran the language server that editors use behind the scenes directly from a script.
Trigger TS2551 and read the message
I installed TypeScript 7.0.2 in a folder created with npm init -y and put the following tsconfig.json in it.
{
"compilerOptions": {
"target": "es2022",
"module": "esnext",
"moduleResolution": "bundler",
"strict": true,
"noEmit": true
},
"include": ["src"]
}
In src/user.ts, I wrote a User type that has email, and a function that builds a mail link. On line 8, I misspelled email as emial.
export type User = {
id: number;
name: string;
email: string;
};
export function mailLink(user: User): string {
return `mailto:${user.emial}`;
}
When I ran npx tsc, it printed the following error and exited with code 1.
$ npx tsc
src/user.ts(8,25): error TS2551: Property 'emial' does not exist on type 'User'. Did you mean 'email'?
(8,25) means line 8, column 25, which is the position of emial in user.emial. The message means: "The User type has no property named emial. Did you mean email?"
With --pretty, the output also shows where the suggested name is declared in the type. (I removed the control characters used for color.)
$ npx tsc --pretty
src/user.ts:8:25 - error TS2551: Property 'emial' does not exist on type 'User'. Did you mean 'email'?
8 return `mailto:${user.emial}`;
~~~~~
src/user.ts:4:3 - 'email' is declared here.
4 email: string;
~~~~~
Found 1 error in src/user.ts:8
The 'email' is declared here. line shows where the suggested email property is declared. This line tells you which property of which type the compiler compared against. I'll test the case where the type is in a separate file later.
Changing to the suggested name removes the error
I changed user.emial on line 8 to user.email and ran npx tsc. It printed nothing and exited with code 0.
The same applies to browser APIs. When I wrote getElementByID, with a capital D, instead of getElementById, I got TS2551 and the correct name was suggested.
const app = document.getElementByID("app");
if (app) {
app.textContent = "読み込みました";
}
$ npx tsc
src/page.ts(1,22): error TS2551: Property 'getElementByID' does not exist on type 'Document'. Did you mean 'getElementById'?
After I changed it to getElementById, the exit code was 0.
Fix it with an editor quick fix
According to the Code Actions section of the VS Code reference, if you place the cursor on a red squiggle and select the lightbulb icon, or use the Quick Fix command, the editor shows a list of fixes you can apply on the spot. For TypeScript, the TypeScript language service builds this list. So I had the language service open the same src/user.ts and asked it for quick fixes.
The TypeScript 5.9.3 tsserver returned three quick fixes. A small script I wrote prints the returned JSON in a readable form.
typescript: 5.9.3
diagnostics (1):
8:25-8:30 code=2551 Property 'emial' does not exist on type 'User'. Did you mean 'email'?
codeFix [spelling] Change spelling to 'email'
edit src/user.ts 8:25-8:30 -> "email"
codeFix [fixMissingMember] Declare property 'emial'
edit src/user.ts 1:21-1:21 -> "\n emial: any;"
codeFix [fixMissingMember] Add index signature for property 'emial'
edit src/user.ts 1:21-1:21 -> "\n [x: string]: any;"
Choose the first one, Change spelling to 'email'. It replaces emial on line 8 with email.
The second fix, Declare property 'emial', and the third fix, Add index signature for property 'emial', also remove the error. However, they change the User type. They add a property emial: any; with your typo, or they add [x: string]: any;, which accepts any name. Don't choose them when you want to fix a typo.
I sent the same request to the TypeScript 7.0.2 language server (tsc --lsp --stdio). The diagnostic message was the same as tsc's, and it also returned the location of 'email' is declared here. However, it returned no quick fixes. In the 7.0.2 source, only three kinds of quick fix are registered, such as adding an import (codeactions.go in typescript-go v7.0.2). In editors that use this language server, you must read the suggestion in the message and fix the name by hand.
If the type definition has the typo, rename the symbol
The suggestion comes from the names written in the type. If the typo is in the type definition, the suggestion is the wrong name.
In the following example, I wrote emial in the User type in src/types.ts. The existing src/profile.ts uses that name, user.emial, so it has no error. In the new file src/mail.ts, I wrote the correct user.email.
// src/types.ts
export type User = {
id: number;
name: string;
emial: string;
};
// src/profile.ts
import type { User } from "./types";
export function profileLine(user: User): string {
return `${user.name}(${user.emial})`;
}
// src/mail.ts
import type { User } from "./types";
export function mailLink(user: User): string {
return `mailto:${user.email}`;
}
$ npx tsc
src/mail.ts(4,25): error TS2551: Property 'email' does not exist on type 'User'. Did you mean 'emial'?
The error appears in mail.ts, which I wrote correctly, and the suggestion is the misspelled emial. If you follow the suggestion, you spread the wrong name. With --pretty, the declaration of the suggested name points to types.ts, which is in a different file.
$ npx tsc --pretty
src/mail.ts:4:25 - error TS2551: Property 'email' does not exist on type 'User'. Did you mean 'emial'?
4 return `mailto:${user.email}`;
~~~~~
src/types.ts:4:3 - 'emial' is declared here.
4 emial: string;
~~~~~
Found 1 error in src/mail.ts:4
When a Did you mean name looks wrong, use the is declared here. line to go to the type definition.
You need to fix the type definition. However, when I changed only emial to email in types.ts, user.emial in profile.ts produced an error.
$ npx tsc
src/profile.ts(4,31): error TS2551: Property 'emial' does not exist on type 'User'. Did you mean 'email'?
As the Rename Symbol section of the VS Code reference describes, the rename command also updates the uses in other files.
I asked the TypeScript 7.0.2 language server to rename emial on line 4 of types.ts to email. It returned the following two edits.
rename 4:3 -> email:
edit src/types.ts 4:3-4:8 -> "email"
edit src/profile.ts 4:31-4:36 -> "email"
These are the type definition and user.emial in profile.ts. mail.ts is not included, because its name was already correct. After I applied these two edits, npx tsc exited with code 0.
When there is no suggestion, you get TS2339
Even when a name is similar, you do not always get TS2551. If no suggestion is found, you get TS2339 without Did you mean. I tried several kinds of typos with the same User type.
type User = {
id: number;
name: string;
email: string;
};
declare const user: User;
user.nmae;
user.nam;
user.userName;
user.Name;
const { emial } = user;
$ npx tsc
src/no-hint.ts(9,6): error TS2339: Property 'nmae' does not exist on type 'User'.
src/no-hint.ts(10,6): error TS2551: Property 'nam' does not exist on type 'User'. Did you mean 'name'?
src/no-hint.ts(11,6): error TS2339: Property 'userName' does not exist on type 'User'.
src/no-hint.ts(12,6): error TS2551: Property 'Name' does not exist on type 'User'. Did you mean 'name'?
src/no-hint.ts(13,9): error TS2339: Property 'emial' does not exist on type 'User'.
nmae, which swaps two letters in name, got no suggestion. The 5-letter emial got email as a suggestion, but the 4-letter name did not get a suggestion for the same kind of swap. The source that selects suggestions (typescript-go v7.0.2) sets a limit on how many differences are allowed, based on the length of the name. Shorter names allow fewer differences. Names with very different lengths, such as userName and name, are not suggested either.
Name, which differs from name only in case, got TS2551. The source that counts the differences between two names also counts a case-only difference as much smaller than a difference in other characters.
With destructuring (const { emial } = user;), the 5-letter emial got no suggestion, and I got TS2339. When you see TS2339, first compare the name with the type definition to check whether it's a typo.
Other error codes that include suggestions
Other errors also include Did you mean suggestions. I tested a misspelled property name in an object literal and a misspelled variable name.
type User = {
id: number;
name: string;
email: string;
};
const user: User = { id: 1, name: "たま", emial: "tama@example.com" };
const userName = user.name;
console.log(usrName);
$ npx tsc
src/other-codes.ts(7,41): error TS2561: Object literal may only specify known properties, but 'emial' does not exist in type 'User'. Did you mean to write 'email'?
src/other-codes.ts(10,13): error TS2552: Cannot find name 'usrName'. Did you mean 'userName'?
A typo in an object literal assigned to a typed variable gives TS2561, and a typo in a variable name gives TS2552. The error codes differ, but the fix is the same as for TS2551: compare the suggested name with the type definition, then rewrite your code.





