Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
77 views
in Technique[技术] by (71.8m points)

javascript - Correct way to export a class with flow?

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?

question from:https://stackoverflow.com/questions/65899281/correct-way-to-export-a-class-with-flow

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...