should you publish your flow-typed folder to NPM?

末鹿安然 提交于 2019-12-11 04:42:30

问题


I'm wondering if and under what conditions you should publish your flow-typed folder to NPM in your packages. Perhaps (and what I've been thinking) the answer is never, and it's up to application developers to use flow-typed themselves, but perhaps flow-typed install only picks up definitions for dependencies they have declared themselves, rather than dependencies within packages.

So in short, if your package has non-peer flow-typed dependencies, should I be publishing my flow-typed folder or I should I npmignore it?


回答1:


You should never publish this folder. I don't think anything bad will happen if you do publish it, besides just unnecessarily increasing your package size. But nothing good will happen either.

The point of flow-typed is that if you use those library definitions, Flow does not have to check the library code. Instead, it takes the library definitions as given. If I consume your library, Flow in my project is not type checking your library. Therefore, it does not need to know anything about your dependencies.

Of course, this hinges upon you publishing your library interface to flow-typed as well. Unfortunately, the tools do not yet exist to make this easy, but it is the correct thing to do. If you just publish your source to npm, clients may be using a different version of Flow than you used, and so they may see unactionable error messages that are simply due to version differences (since nearly every Flow release is a breaking change). You may also have different .flowconfig options which could result in errors even if the Flow version matches.



来源:https://stackoverflow.com/questions/43844062/should-you-publish-your-flow-typed-folder-to-npm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!