Short answer: TypeScript is structural — it checks your code against the declared type, not against whatever the value happens to contain at runtime. 'Property X does not exist on type Y' means the compiler cannot prove X is there. The right fix depends on which of four situations you are in: a typo or missing field, a value whose type is too narrow or too vague, a union type where only some members have the property, or stale third-party types. Reaching for any silences the error and hides the bug; fix the type instead.
Situation 1: the property genuinely isn't there
Check the spelling first — userNmae vs userName is the most common cause of this error, and the compiler is right. Next, check the shape: if you build the object yourself, the property may genuinely be missing from the literal, or the API response may not include it in every case. If a field is sometimes absent, declare it optional (field?: string) and handle undefined at the use site with optional chaining or a default, instead of pretending it is always present.
Situation 2: the type is too vague
JSON.parse returns any in older setups and unknown in stricter ones, and an API helper typed as returning object or Record<string, unknown> gives you no properties at all. The fix is to declare what you actually expect: define an interface for the response shape and annotate the result (const data = (await res.json()) as UserResponse is a claim — validate the shape at runtime first if the data comes from outside your control). For data you construct, prefer satisfies over as: it checks the value against the type without widening or lying about it.
Situation 3: unions — the property exists on some members only
If the value is Cat | Dog and only Dog has breed, the compiler correctly refuses pet.breed — a Cat has no breed. Narrow first: check a discriminant field (pet.kind === 'dog'), use the in operator ('breed' in pet), or write a type guard function (function isDog(p: Pet): p is Dog). After narrowing, the property is available and the check is real, not asserted. The same pattern applies to API responses that vary by status: narrow on the status field before touching the payload.
Situation 4: stale or missing library types
When the property exists at runtime but the installed types predate it, update the package and its @types package — the types may simply be old. If the library ships no types for a newer API, extend them locally with declaration merging (declare module 'lib' { interface Thing { newProp: string } }) rather than casting to any. And when a DOM or platform API is newer than your lib setting in tsconfig, raising lib (for example adding 'DOM.Iterable') is the correct fix, not a cast.
The one fix to avoid
(value as any).property compiles and then fails at runtime in exactly the way the error was warning you about — with no stack clue, because you told the compiler to stop checking. If you must assert, assert to the narrowest correct type, and add a runtime check alongside it. A type error is the compiler doing its job; the goal is a type that matches reality, not silence.
Try it
Paste a sample API response into the JSON to TypeScript tool — it generates interfaces from the real shape, including optional fields for keys that are missing from some items, so the next version of your type matches the data instead of fighting it.