Flow-typed: What is the preferred way for a module to provide its own libdef?

Created on 2 Nov 2017  路  4Comments  路  Source: flow-typed/flow-typed

I'm writing a Node module. I'm using Flow in development. I'm building my code with Babel to compile and strip the type annotations, and then publishing the Babel output to npm.

I would like to expose my module's types so that dependent projects (if they are also using Flow) may automatically use types.

My question: should I PR a libdef into flow-typed after publishing my module? Or is it better to just include .js.flow file(s) with my published code?

(If it's the latter, is there any documentation on the best practices for doing this? Is there a way I can auto-generate the .js.flow files? Is there a good example of a small Node module that does this in the ideal way?)

question

All 4 comments

Good question! I'm not too sure myself, but I've reached out to someone who would have a better idea.

The typed source code works as a .js.flow file. We just copy and rename them on build.

(note that it's impossible to provide different .js.flow files for different versions of flow)

This is now in the FAQ:

https://github.com/flowtype/flow-typed/wiki/FAQs#what-is-the-preferred-way-for-a-module-to-provide-its-own-libdef

Was this page helpful?
0 / 5 - 0 ratings