Scaleup Infotech
Scaleup Infotech.
Back to Blog
Bug Fixes8 min read

Fix TypeScript 'Property does not exist on type' Error

Scaleup Infotech

Scaleup Infotech

Software & Marketing Agency

Mar 21, 2026
Fix TypeScript 'Property does not exist on type' Error
TypeScriptTypesNarrowing

Error TS2339 is TypeScript doing its job: you are reading a property it cannot prove exists. The right fix is almost never any — it is giving the compiler the type information it is missing.

The Error

Property 'name' does not exist on type '{}'. (ts2339)

Fix 1: Type Your API Responses

response.json() returns any/unknown. Tell TS what shape it is:

ts
interface User { id: string; name: string; email: string; }

const res = await fetch("/api/user");
const user = (await res.json()) as User;
console.log(user.name); // ✅ known property

Fix 2: Narrow Union Types Before Access

ts
type Shape =
  | { kind: "circle"; radius: number }
  | { kind: "square"; side: number };

function area(s: Shape) {
  if (s.kind === "circle") return Math.PI * s.radius ** 2; // narrowed
  return s.side ** 2;
}

Fix 3: Index Signatures for Dynamic Keys

ts
const config: Record<string, string> = {};
config["theme"] = "dark"; // ✅ any string key allowed

Fix 4: Augment a Third-Party Type

When a library is missing a property you need (e.g. a custom field on the Express Request), declare it once via module augmentation rather than casting everywhere.

Avoid the any Escape Hatch

Casting to any silences the error but throws away every guarantee TypeScript gives you. Prefer typing the source. If you must escape, use unknown and narrow.

Share this article:

Keep Reading

Ready to implement these ideas?

Work With Scaleup Infotech