TS2551: Property 'X' does not exist on type 'Y'. Did you mean 'Z'?
You're accessing a property that doesn't exist on the object's type — most often a typo, which TypeScript is helpfully guessing at with the "Did you mean" suggestion. Fix the spelling if it's a typo, or if the property genuinely should exist, check that you're importing/using the type you think you are (it may be a stale or differently-shaped version).
What causes this error
TypeScript compares the property name you accessed against the actual members of the object's type. When the name is close to an existing member (an edit-distance match), it adds a "Did you mean 'Z'?" suggestion — most of the time that suggestion is exactly the fix, since it's genuinely a typo rather than a deeper type mismatch.
The Fix
interface User {
firstName: string;
lastName: string;
}
const user: User = { firstName: 'Ada', lastName: 'Lovelace' };
// Wrong — typo
console.log(user.firstname); // TS2551: Did you mean 'firstName'?
// Fix — correct the spelling
console.log(user.firstName);If there's no typo and the property genuinely should exist, double-check you're importing the right type — a stale build, a duplicate type definition, or a differently-versioned package can leave you looking at an outdated shape.
Common causes / variations
- A straightforward typo in a property name (the most common case by far)
- Confusing two similarly-named types with slightly different shapes
- An outdated generated type (e.g. from an API client or ORM) that hasn't been regenerated after a schema change
Related errors
See also: TS2322 Type is not assignable, TS7053 Element implicitly has an any type.
Comments
Loading comments...