HomePhabricator
Diffusion Comm a9e27da65312

[Flow202][native][skip-ci] [41/x] Fix type error in native/themes/colors.js

Description

[Flow202][native][skip-ci] [41/x] Fix type error in native/themes/colors.js

Summary:
The new Flow was printing this error:

Error ------------------------------------------------------------------------------------------ themes/colors.js:304:10

Cannot return StyleSheet.create(...) because an index signature declaring the expected key / value type is read-only in
Styles [1] but writable in object type [2]. [incompatible-variance]

 [2] 285| ): StyleSheetOf<IS> {
 [1] 286|   const result: Styles = {};
        :
     301|     }
     302|     result[key] = filledInStyle;
     303|   }
     304|   return StyleSheet.create(result);
     305| }
     306|
     307| function styleSelector<IS: Styles>(

Styles actually isn't read-only, but React Native's type for StyleSheet.create limits its type param to be read-only.

I fixed it by making our StyleSheetOf type read-only. However, that exposed more errors where we use typeof unboundStyles, so I had to add $ReadOnlys to all of those.

NOTE: CI will fail on this diff. I considered the possibility of fixing Flow errors BEFORE upgrading Flow, but it wasn't possible... in some cases, the fixes to support the new version of Flow caused errors in the old version. I could have hidden these type errors with $FlowFixMe lines and then later revert those, but that seemed like too much busy work.

Depends on D10024

Test Plan: Confirm the Flow errors go away

Reviewers: ginsu

Reviewed By: ginsu

Subscribers: tomek

Differential Revision: https://phab.comm.dev/D10025

Details

Provenance
ashoatAuthored on Nov 23 2023, 9:05 AM
Reviewer
ginsu
Differential Revision
D10025: [Flow202][native][skip-ci] [41/x] Fix type error in native/themes/colors.js
Parents
rCOMM271ed1970b25: [Flow202][native][skip-ci] [40/x] Fix type error in…
Branches
Unknown
Tags
Unknown