Even though RMWC sources have Flow type definitions, it's not present in ES5 version when library module is installed with yarn (npm).
What's the correct (possible) way to include/define those types?
Currently, I'm just forced to create empty stubs e.g. flow-typed create-stub rmwc/[email protected]...
Thanks for that! Been wondering this myself, definitely want to support this
This will hopefully be fixed in the MDC 32 release that is pending right now. I've included the ES6 src as well as a workaround that is supposed to export the flow types.
@romanlv check this out in 1.4.0 and let me know if it fixes your issue.
@jamesmfriedman it looks like it works only when components are imported from root namespace e.g.
import { Switch } from 'rmwc'; but not with selective import import { Switch } from 'rmwc/Switch'; (which I want to keep)
Indeed, when I inspect rmwc folder in node_modules it has only one index.js.flow file in root
That鈥檚 great to know. I鈥檓 guessing this fix is as simple as adding index.flow files to the individual directories as well. I鈥檒l look into this more for the next release but at least moving in the right direction.
Made a change for the next release, I'm now exporting a flow index file from every module, so you should be able to import rmwc/Button, but it will pull the flow types from rmwc/src/Button.
@romanlv 1.5 was just released. Let me know if the changes helped your workflow.
@jamesmfriedman I run into several issues with *.flow files in this release (and most likely it didn't work in the previous one, sorry, it must have used stub which was saved in `flow-typed' dir)
I did some investigation, it looks like using flow-copy-source can be an easier solution, instead of commiting *.flow file to the repo (which didn't work for me)
I tried to experiment with it in test-repo using something like
find node_modules/rmwc/ -name '*.flow' -exec rm {} \;
npx flow-copy-source -v node_modules/rmwc/src/ node_modules/rmwc/
yarn flow check
Which picked up definitions, but it looks like there are some errors with flow in the rmwc project itself, indeed npx flow check gives me 113 errors, I think you should add this check to circleci config ...
I can try to create a PR that uses flow-copy-source but there should be no flow errors in the project to begin with...
@romanlv thanks for the tip. A few things.
Good news @romanlv, this should be fixed in 1.6!.
I've tested with VScode and I'm getting autocomplete (although the prop descriptions don't come through).
Take a look, let me know if it's working for you
Most helpful comment
@romanlv thanks for the tip. A few things.