I want to write es6 class:
class SomeClass {
static prop = 123
method() {
}
}
How to get access to static prop
from <
but in typescript this.constructor.prop causes error "TS2339: Property 'prop' does not exist on type 'Function'".
Typescript does not infer the type of constructor
to be anything beyond Function
(after all ... the constructor might be a sub class).
So use an assertion:
class SomeClass {
static prop = 123;
method() {
(this.constructor as typeof SomeClass).prop;
}
}
More on assertions