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

chore: Avoid inexact object types #82

Closed
wants to merge 1 commit into from

Conversation

nmn
Copy link
Contributor

@nmn nmn commented Apr 11, 2024

A follow up from my previous PR #81

This PR removes a few cases where inexact object types are used and replaces them with
{ +[string]: mixed }

This is a quirk of how inexact object types work. They do not allow reading any of those additional keys which may or may not exist on the object. They only loosen the constraints for what objects can be given when such a type is used.

This is particularly problematic when {...} is used as a stand-in for "any object". According to flow, an exact object type does not satisfy {...}.

Using { +[string]: mixed } fixes all of these problems and works in all scenarios for at least the last 30 versions of Flow.

Copy link

compressed-size: runtime library

Size change: 0.00 kB
Total size: 18.80 kB

View unchanged
Filename: gzip (minify) kB size kB change % change
./packages/react-strict-dom/dist/dom/index.js 2.99 (9.00) 0.00 (0.00) 0.0% (0.0%)
./packages/react-strict-dom/dist/dom/runtime.js 0.95 (2.33) 0.00 (0.00) 0.0% (0.0%)
./packages/react-strict-dom/dist/native/index.js 14.85 (46.47) 0.00 (0.00) 0.0% (0.0%)

@nmn nmn requested review from necolas and ksheedlo April 11, 2024 02:01
@necolas necolas closed this in f36a080 Apr 11, 2024
@nmn nmn deleted the chore/clean-up-types branch April 11, 2024 08:35
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