[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