- Error
- Reported by the type checker
TS2339
Property '{0}' does not exist on type '{1}'.
A property is read on a type that doesn't declare it. Check the spelling, narrow a union first, or add the property to the type.
What it means
The type of the expression before the . has no member with that name. On a union, the property must exist on every member. Values typed {} or object have no properties.
Example
const user = { name: "Ada" };
export const email = user.email;
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(3,27): error TS2339: Property 'email' does not exist on type '{ name: string; }'.
Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.
How to fix
- Fix the spelling, or add the property to the type.
- For a union, narrow first (
if ("email" in user), a discriminant check, ortypeof). - For data from outside the program, declare its type and validate it.