Accessing a field or method not defined in the type interface or type union.
TypeScript statically checks object property access against the declared interface or type. If you try to access `obj.foo` when `foo` is not part of `obj`'s type definition, TS2339 is raised at compile time.
Common causes: typos in property names, missing field declarations on custom interfaces, or attempting to access a field on a union type (`TypeA | TypeB`) where the field is only present on `TypeA`.
1interface User {2 userId: string;3 name: string;4}5 6const user: User = { userId: "u1", name: "Sarah" };7console.log(user.email); // Error TS2339: Property 'email' does not exist on type 'User'1interface User {2 userId: string;3 name: string;4 email?: string; // Fix 1: Declare optional property5}6 7const user: User = { userId: "u1", name: "Sarah", email: "sarah@example.com" };8 9// Fix 2: Type narrowing for union types10type Admin = { role: "admin"; permissions: string[] };11type Guest = { role: "guest" };12type Person = Admin | Guest;13 14function getPermissions(p: Person) {15 if (p.role === "admin") {16 return p.permissions; // TS narrows p to Admin17 }18 return [];19}Simulate standard system builds to trigger compiler trace records and track memory crashes locally.
The `User` interface defines `id` and `name`. TypeScript prevents accessing `email` because it cannot guarantee `email` exists at runtime.