Skip to content
JS
JavaScript error

TypeError

The JavaScript exception "can't access private field or method: object is not the right class" or "can't set private field: object is not the right class" occurs when a private field or method is get or set on an object that does not have this private element defined.

Reference entryJavaScriptFetched
TypeError: Cannot read private member #x from an object whose class did not declare it (V8-based)
As listed by MDN Web Docs
TypeError: Cannot write private member #x to an object whose class did not declare it (V8-based)
As listed by MDN Web Docs
TypeError: can't access private field or method: object is not the right class (Firefox)
As listed by MDN Web Docs
TypeError: can't set private field: object is not the right class (Firefox)
As listed by MDN Web Docs
TypeError: Cannot access invalid private field (evaluating 'this.#x') (Safari)
As listed by MDN Web Docs
Category
TypeError
Severity
error
Runtime
both
or press Cmd/Ctrl + Enter. The text is only sent to this site to match it.
Source: MDN Web Docs. Data fetched 2026-09-25T01:48:37.273Z.