- Error
- Reported by the type checker
TS2576
Property '{0}' does not exist on type '{1}'. Did you mean to access the static member '{2}' instead?
An instance is used to read a static member. Read it through the class name instead, as ClassName.member.
What it means
Static members belong to the class itself, not to its instances. Reading one through an instance (or through this in an instance method) finds nothing, and the message points to the static member with the same name.
Example
class Counter {
static max = 10;
}
const c = new Counter();
c.max;
export {};
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(5,3): error TS2576: Property 'max' does not exist on type 'Counter'. Did you mean to access the static member 'Counter.max' instead?
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
- Read the member through the class:
Counter.max. - If each instance needs its own value, make it an instance property instead of
static.