Flow: Develop a library with flowtype

Created on 1 Sep 2016  路  6Comments  路  Source: facebook/flow

I'm currently developing a library using flowtype. And I'm using babel with preset-0. Also, transpile it before npm publish.

After transpiling, the type annotation has been thrown away, so projects using my library won't have benefits of type checking. I have tried some way to handle this problem.

  1. directly import the original source in the project. which means this project also need to have preset-0.
  2. use flow-comments babel plugin. However, I cannot make it works.
  3. use another declaration file. But this heavily violates DRY.

Is there a the suggested way to do this?
And for point 2, am I doing something wrong?

Thanks

question

All 6 comments

See https://github.com/facebook/flow/issues/1996#issuecomment-230919868

Just as an example of a project setup, I have this "preversion" script in one of my projects: https://github.com/rpominov/fun-task/blob/9e5b512e4d4e2b6aeaf967ca63991afa0b3c885b/package.json#L10

@rpominov Thanks!

In the changelog, the existence of a gen-flow-files command is hinted at!

It's supposed to be alpha-level, but try:

flow gen-flow-files --out-dir lib src/index.js

@LPGhatguy yeah I saw that....this is exactly what I want.

I _think_ the .js.flow build step strategy is well enough documented now that we can close this issue.

I _think_ the .js.flow build step strategy is well enough documented now that we can close this issue.

Where I can read about this strategy?

Was this page helpful?
0 / 5 - 0 ratings