Flow version: 0.102.0
The following should typecheck without errors.
type Fn = () => any
class A {
#foo: Fn = () => 42
callFoo() {
this.#foo()
}
}
Flow gives an error
6: this.#foo()
^ Cannot call `this.#foo` because property `foo` is missing in `A` [1].
References:
3: class A {
^ [1]
Changing the call site to
const foo = this.#foo
foo()
works as expected.
Issue #6254 is related, but seems to be more about defining private methods, which is a separate ES proposal. This issue is more about using private fields that can already be defined just fine.
Good find, I'm working on a fix to this now.
Any news?
As a temporary solution, do this:
this.#foo.call(this, /* args */)
instead of:
this.#foo(/* args */)
Still not work.
Most helpful comment
Good find, I'm working on a fix to this now.