New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flow any fixes #1280
Merged
Merged
Flow any fixes #1280
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mwiencek
force-pushed
the
flow-any-fixes
branch
from
November 20, 2019 08:48
4819c34
to
dcdfe18
Compare
reosarevok
reviewed
Nov 26, 2019
This allows us to remove a use of `any`. While we could also fix this by keeping OauthTypeT but checking that it's equal to 'installed' or 'web' in handleOauthTypeChange, that sort of check would be dead weight, and keeping OauthTypeT doesn't actually provide any type safety here: by casting the string from the select to `any` and then to OauthTypeT, we're trusting what we get from the browser in any case.
Instead of putting all the button props into an object type, we can inline them into the JSX element.
This was used to avoid an additional allocation per expand2 call, but that's a premature optimization. Fixes some questionable uses of `any` and removes some confusing code comments.
The main "fix" here is that LinkableEntity must be a disjoint union distinguished by the entityType property. The changes to MinimalCoreEntityT and MinimalAnnotatedEntityT (to make them exact) were part of an alternate fix I was working on, and not strictly necessary anymore, but I kept them because they're technically correct.
This was used by EntityLink to determine whether there was a name variation when `content` was a React element (rather than a string). It tried to recurse into the React element tree and figure out the actual text content of the element, sort of like `.textContent` would do in a web browser. But this didn't work at all if the React element was a custom component: by definition it's not rendered yet, so it's impossible to know what the text content could be. I also found only one actual case where this might be needed, and simply changed that to set nameVariation directly. We still set nameVariation automatically in cases where `content` is a string. Removes a usage of the `any` Flow type.
This is deprecated: https://reactjs.org/docs/react-dom.html#finddomnode Fixes a use of the `any` Flow type in Tooltip.js.
Flow doesn't type the result of Object.entries in the way that we'd like for exact object types yet. However, iterating over the keys works fine and doesn't degrade readability at all.
Fixes a use of `any` in wrapGettext.js. Note: flow-typed/npm/jed_v1.x.x.js is our own definition, not from the flow-typed repository, so local modifications are fine. We use a fork of Jed (on github at mwiencek/Jed), so perhaps it's better to move the types there as a Flow declarations file.
mwiencek
force-pushed
the
flow-any-fixes
branch
from
December 5, 2019 01:34
dcdfe18
to
bb9c937
Compare
reosarevok
approved these changes
Dec 5, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be fine now :)
yvanzo
approved these changes
Dec 10, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR mainly aims to reduce the number of uses of the
any
type. (There's only one remaining after this.) Where fixing the type implicated some smelly code, I fixed the code too.