Skip to content
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

react-intl types: Move definitions out of flow-typed libdef #5311

Merged
merged 11 commits into from
Apr 1, 2022

Conversation

chrisbobbe
Copy link
Contributor

@chrisbobbe chrisbobbe commented Mar 25, 2022

This covers Greg's responses starting from #5308 (comment) and moves the react-intl libdef into a .js.flow file.

Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chrisbobbe! This all looks good except one item below.

{|
formats: mixed,
messages: mixed,
timeZone: mixed,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't quite right -- to match the intended behavior it needs to be timeZone?: mixed, unfortunately:

 * A limitation: this implementation can't tell which properties are
 * *optional* in T, i.e. spelled with `?:`, as in `foo?: number`.  Instead,
 * properties in the result will be optional or required based on how they
 * are in U.  To avoid confusion, be sure to make the same properties
 * optional in U as are optional in T.

I.e., IntlConfig has timeZone optional, so this needs to have timeZone optional as well in order to make it optional in the result.

(Similarly some other properties.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this! I think I've got them all in the new revision.

We moved this stuff to our types/@react-navigation/ in zulip#5263, and we
already have a line for that in this file.
This doesn't actually improve Flow coverage or change any types;
both Omit and Exclude are utility types in TypeScript that Flow
doesn't have. But in the original TypeScript, the use of Exclude for
these was a mistake; they should have been Omit; see discussion at
  zulip#5308 (comment)

We're about to go through all uses of Omit and replace them with
something that works; these will then be fixed.
The React$Component type asks for a type argument, and one wasn't
getting passed.

Instead of working out what exactly to pass, use this form, which is
more concise and probably more appropriate anyway.
…lity

As suggested by Greg:
  zulip#5308 (comment)

This definition is copied from our src/generics.js. When we move
this libdef to a .js.flow file, we'll deduplicate the definition by
importing it from src/generics.
To see that only whitespace is changed, view the diff with

  git diff -w
@chrisbobbe chrisbobbe force-pushed the pr-react-intl-js-flow branch from 84a2abd to 96524ab Compare April 1, 2022 00:02
@chrisbobbe
Copy link
Contributor Author

Thanks for the review! Revision pushed.

@gnprice gnprice merged commit 96524ab into zulip:main Apr 1, 2022
@gnprice
Copy link
Member

gnprice commented Apr 1, 2022

Thanks! Looks good -- merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants