fix: flow typing of React API with Flow 0.92 #448
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Nice library! ;) Very well done :D
I've run into a few flow errors when trying to add it on my project (https://github.com/4ian/GDevelop) with Flow 0.92.
I've made a few fixes, hope they are ok.
Changes
createLinguiPublisher
ormakeLinguiPublisher
as it's returning an object rather than being a constructor (i.e: it's not modifyingthis
). I've changed the name and changed its usage to remove thenew
.LinguiPublisher
when googling it. If you think this is breaking the API, we can go back to have it being namedLinguiPublisher
and have the type namedLinguiPublisherType
.update
ofLinguiPublisher
can be called without any arguments. But the typing was incorrect then. I've named the parameter (param
, not very original) and checked for its existence before destructuring it.|| null
to ensure you're not returning undefined in renders.Test plan
yarn lint
and got in pseudoLocalize.test.js:but this seems to be unrelated to my changes?
yarn flow
is still passing.flow
(with flow version 0.92.0) is down from 5 errors to 2, that are inpackages/cli/src/api/compile.js
(line 142 and 144):I've not fixed them because my goal was to get the React API without flow errors :) Original errors where (when using js-lingui in a React project):
Also if you feel more comfortable fixing yourself the issues with Flow 0.92 rather than merging/asking changes on this PR, feel free to steal my fixes :)