TS2551Semantic Error
Since TS 2.4

Fix TS2551: Property Does Not Exist - Did You Mean?

Learn why TypeScript throws TS2551 with a 'did you mean' suggestion for misspelled property names, and how to fix typos.

error TS2551: Property 'X' does not exist on type 'Y'. Did you mean 'Z'?

What This Error Means

TS2551 is a friendlier version of TS2339 ("Property does not exist on type"). It fires when you try to access a property that doesn't exist on a type, but TypeScript detects a similarly-named property and offers a "Did you mean?" suggestion.

This is one of TypeScript's most helpful error messages because it usually identifies the exact fix. The suggestion is based on string similarity (Levenshtein distance), so it catches common typos like swapped letters, missing characters, or wrong casing.

// The general shape of the error:
// Property 'naem' does not exist on type 'User'. Did you mean 'name'?
//           ~~~~                                               ~~~~
//           what you wrote                                     what exists

Common Causes

1. Simple Typos in Property Names

The most common cause — you misspelled a property name when accessing it.

// ❌ Broken
interface Product {
  name: string
  price: number
  description: string
}
 
function formatProduct(product: Product) {
  return `${product.naem} - $${product.pirce}`
  //                ~~~~              ~~~~~
  // Error: Property 'naem' does not exist on type 'Product'. Did you mean 'name'?
  // Error: Property 'pirce' does not exist on type 'Product'. Did you mean 'price'?
}
// ✅ Fixed — correct the typos
function formatProduct(product: Product) {
  return `${product.name} - $${product.price}`
}

2. Wrong Casing (camelCase vs snake_case)

When working with APIs that return snake_case properties, it's easy to accidentally use camelCase or vice versa.

// ❌ Broken
interface ApiResponse {
  user_id: number
  first_name: string
  last_name: string
  created_at: string
}
 
function displayUser(response: ApiResponse) {
  console.log(response.firstName)
  //                   ~~~~~~~~~
  // Error: Property 'firstName' does not exist on type 'ApiResponse'.
  //        Did you mean 'first_name'?
}
// ✅ Fixed — use the correct casing
function displayUser(response: ApiResponse) {
  console.log(response.first_name)
}

3. Accessing a Property From the Wrong Object

Sometimes the property exists, just on a different type than the one you're accessing.

// ❌ Broken
interface Order {
  orderId: string
  items: OrderItem[]
  totalAmount: number
}
 
interface OrderItem {
  productName: string
  quantity: number
}
 
function getOrderSummary(order: Order) {
  return order.productName
  //          ~~~~~~~~~~~
  // Error: Property 'productName' does not exist on type 'Order'.
  //        Did you mean to access it on 'OrderItem'?
}
// ✅ Fixed — access the property on the correct object
function getOrderSummary(order: Order) {
  return order.items.map((item) => item.productName)
}

How to Fix It

  1. Check the suggestion. In the vast majority of cases, the "Did you mean?" suggestion is correct. Rename your property access to match.

  2. Use your editor's quick-fix. Most editors (VS Code, WebStorm, etc.) offer a one-click fix for TS2551. Hover over the error and select the suggested correction.

  3. If the property should exist on the type, add it to the interface or type definition rather than just renaming your access:

// If you genuinely need a new property, extend the type
interface Product {
  name: string
  price: number
  sku: string // add the missing property
}
  1. Check for inconsistent naming conventions. If your codebase mixes camelCase and snake_case, consider normalizing the data at the boundary (e.g., when parsing API responses) so the rest of your code uses a consistent style.

  2. Search for other occurrences. If you misspelled a property once, you probably misspelled it elsewhere. Use find-and-replace to catch all instances.

FAQ

What causes TS2551?

TS2551 fires when you access a property that doesn't exist on a given type, but TypeScript finds a similar property name on that same type. It's essentially a typo detector. TypeScript compares what you wrote against all known properties on the type and, if it finds a close match, includes the "Did you mean?" suggestion in the error message.

If there's no similar property at all, you'll get TS2339 instead (the plain "Property does not exist" error without a suggestion).

How do I fix the did-you-mean suggestion?

The simplest fix is to accept the suggestion and rename the property to match what TypeScript recommends. In VS Code, you can press Ctrl+. (or Cmd+. on macOS) on the error to apply the quick fix automatically. If you believe the property genuinely should exist but doesn't, you need to add it to the type definition.

Why doesn't TypeScript auto-fix this?

TypeScript's compiler is intentionally conservative — it reports errors but doesn't modify your source code. The "Did you mean?" suggestion is a hint, not a certainty. You might have intended a completely different property, or the type itself might need updating. Your editor's language service can apply these fixes interactively, giving you the chance to review each one before accepting it.

Related Errors

Related Concepts

Share this reference

Stay Updated

Get the latest TypeScript tips, tutorials, and course updates delivered straight to your inbox.

No spam, unsubscribe at any time.