profiler
profiler copied to clipboard
Add tests for our complex flow typing
We should add some tests to make sure our typing works. My guess is that this broke in the recent Flow upgrade.
┆Issue is synchronized with this Jira Task
Hmm... actually never mind. I misspelled mapStateToProps, and it didn't throw errors. Looking at the type definition, it makes sense why it wouldn't.
Reopening because I believe this is still something we need. It would give us more confidence when changing these complex typings as well as when upgrading flow.
Some key things from my previous research to do this:
- add a custom
suppress_commentto.flowconfigso that we have a more explicit comment than$FlowFixMefor tests; maybe$ExpectErroris a good idea (likeflow-typeddoes). If we specify such a comment but there's no Flow error at this location, Flow will generate a warning. - use the argument
--max-warnings 0when running Flow, so that warnings actually fail flow. (Note: this is new in Flow, before we had to parse Flow's output... Good we don't have to do that now :+1: ) - add a directory
src/test/flowto put the code samples - it's especially important to add code samples that trigger flow errors, but please also add code samples that are correct. We already do have code samples that are correct in the app code, but it's always easier to debug flow issues with simpler code than with the full app code.
Things to especially check:
- [x]
explicitConnect(fromsrc/utils/connect.js) - [ ] HOC
withSize(fromsrc/components/shared/WithSize.js) - [ ] HOC
withViewport(fromsrc/components/shared/chart/Viewport.js) - [ ] (optional) ButtonWithPanel (from
src/components/shared/ButtonWithPanel.js)
We have tests now for the connect.js function.