What is the best way to write flowtype definitions for private modules?

255 Views Asked by At
  1. What is the best way to write flowtype definitions for a module? I am aware of the flow-typed project, is this the best way to write definitions even if you own the library? The documentation is not very clear about this.

  2. flow-typed approach does not work for private modules. What is the recommendation in this case?

1

There are 1 best solutions below

0
On

I'd recommend reading through Authoring and publishing JavaScript modules with Flow.

The short answer is that you can distribute your module with .js.flow files that Flow will read to get type information. Usually these are just copies of your original source code from before the type annotations were deleted, created using the flow-copy-source package.

flow-typed exists to provide definitions for modules that do not provide them automatically, but you can include the type definitions right inside your own modules.