All posts
typescripttypes

Fixing "Property does not exist on type" in TypeScript

Why TypeScript throws Property does not exist on type, and the right fix depending on whether the type or the code is wrong.

SR

Suhail Roushan

August 6, 2026

·
4 min read
·
0 views

Property 'x' does not exist on type 'Y' fires whenever you access a property TypeScript's type information says isn't there — and the fix genuinely depends on which side is actually wrong: sometimes the type definition is incomplete, sometimes your code is accessing something that really shouldn't exist on that value.

This error means TypeScript's static type for a value doesn't include the property you're trying to access — it's not evaluating your actual runtime object, only the declared or inferred type, so the error can appear even when the property genuinely exists at runtime if the type describing that value doesn't account for it.

Why This Error Happens

TypeScript checks property access against the statically known type, not the actual runtime shape of the value. This mismatch commonly happens with union types (where a property only exists on some members), incompletely typed external data, DOM APIs with narrower base types than the specific element you're working with, or genuine typos in property names that TypeScript correctly catches.

Reproducing the Error

A union type narrowing issue:

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

function area(shape: Shape) {
  return shape.radius * shape.radius;
  // Error: Property 'radius' does not exist on type '{ kind: "square"; side: number; }'.
}

radius only exists on one member of the union, so TypeScript won't let you access it without first narrowing which variant you actually have.

Core Concepts Behind This Error

Union types require narrowing before accessing member-specific properties — TypeScript needs proof (via a type guard, a discriminant field check, or an in check) that you're working with the specific union member that has the property, since accessing it without narrowing could be genuinely undefined at runtime for other members.

DOM element types are often narrower than the actual element, since document.getElementById() returns the general HTMLElement | null — accessing element-specific properties (like .value on an input) requires a type assertion or type guard confirming the more specific element type first.

Incompletely typed external data (API responses without an accurate interface, JSON.parse() results typed as any) can produce both false positives and false negatives for this error — the fix in that case isn't suppressing the error, it's writing (or generating) an accurate type for the actual data shape.

Optional chaining (?.) addresses a different problem than this error — optional chaining handles a property that might not exist on a value that could be null/undefined, while this error is about a property TypeScript's type says doesn't exist on this type at all, at any value; conflating the two leads to reaching for the wrong fix.

Fixing "Property Does Not Exist on Type"

Fix 1: Narrow union types with a discriminant check before accessing member-specific properties:

function area(shape: Shape) {
  if (shape.kind === "circle") {
    return shape.radius * shape.radius; // OK, narrowed to circle
  }
  return shape.side * shape.side; // OK, narrowed to square
}

Fix 2: For DOM elements, assert or check the specific element type before accessing element-specific properties:

const input = document.getElementById("email") as HTMLInputElement;
console.log(input.value);

Fix 3: For genuinely incomplete or incorrect types on external data, fix the type definition to match reality rather than suppressing the error at each access site — write an accurate interface, or use a schema validation library that derives the TypeScript type from a runtime schema so the two can't drift apart.

When Is This Error Actually a Real Bug in Your Code, Not the Types?

When you've simply typo'd a property name, or you're trying to access a property that genuinely doesn't exist on any variant of the value's real type — in that case, the fix isn't a type assertion or widening the type, it's correcting the actual code to use the right property or a genuinely different approach. Treat the error as a real bug specifically when the property truly shouldn't exist there, versus a type definition gap when it should.

Preventing This Error in Production

Use discriminated unions with explicit discriminant fields for values that vary in shape, since they let TypeScript narrow types precisely with simple conditional checks rather than needing type assertions. Keep types for external data accurate and, where practical, generated from or validated against a runtime schema, so type definitions and actual data shape can't silently drift apart.

If you hit this error, check first whether it's revealing a real bug (wrong property name, missing narrowing) or an incomplete type definition — the two need genuinely different fixes, and reaching for any addresses neither.

Related posts

Written by Suhail Roushan — Full-stack developer. More posts on AI, Next.js, and building products at suhailroushan.com/blog.

Get in touch