Correct way to export a class with flow?

Viewed 143

After having updated my flow-bin package from 0.142.0 to 0.143.1, I got hundreds of error messages like this one (signature-verification-failure): enter image description here

I know this version of flow made types-first the default mode but still, I don't understand since all of my functions are properly annotated, like in this simple class:

/* @flow */

export class Foo {

  bar = (n: number): number => n + 1;

}

I also tried export default Foo and module.exports = Foo but got the same result. What am I missing here?

1 Answers

Flow wants explicit type annotation on bar:

export class Foo {
  bar: (n: number) => number = n => n + 1;
}

You can use annotate-exports codemod, to fill some of the missing annotations automatically.

Related