TypeScript: Property does not exist on type
Type error: Property 'name' does not exist on type '{}'.In one sentence: TypeScript doesn't know your object has that property, usually because its type was never declared or was guessed wrong.
What it means
TypeScript checks every property you read against the object's type. If the type doesn't list that property, it refuses to build, even when the property really exists at runtime.
This is the most common reason a Vercel or Netlify build fails while `npm run dev` seemed fine: the dev server shows the problem as a warning, but `next build` treats type errors as failures.
Common causes
- State started with no type: `useState({})` or `useState(null)` gives TypeScript nothing to work with.
- Data from `fetch`, Supabase or an API is typed as `{}` or `unknown` instead of your real shape.
- A typo or a renamed field (`user.fullName` vs `user.full_name`).
- The property is optional or only exists on one variant of a union type.
How to fix it
- Declare the shape once with a type or interface, and pass it in: `useState<User | null>(null)`.
- Type API results where they come in: `const data: Product[] = await res.json()`, or use the generated Supabase types.
- Check the exact spelling against the real data (log it once).
- If it can be missing, guard it: `if (user) user.name` or `user?.name`.
- Avoid `as any` or `// @ts-ignore` as the fix: they hide the error and the bug usually comes back at runtime.
Before
const [user, setUser] = useState({});
return <p>{user.name}</p>;After
type User = { id: string; name: string };
const [user, setUser] = useState<User | null>(null);
return <p>{user?.name ?? "Loading…"}</p>;Prompt to paste into your AI tool
My build fails with TypeScript 'Property X does not exist on type'. Add a proper type or interface for this data, type the useState and API response with it, guard values that can be null, and do not use 'as any' or ts-ignore.Still stuck?
Paste your exact error and code. Get a plain-English explanation free, or the full fix for $5.
Related errors
- TypeError: Cannot read properties of undefined
- CORS error: blocked by CORS policy
- Hydration failed: server HTML didn't match the client (Next.js)
- Module not found: Can't resolve '...'
Weekly: the errors breaking vibe-coded apps and how to fix them. Free.
No spam. Unsubscribe anytime.