-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Fix/simplify invariant for ColorSchemeName, align manual typedef #53397
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
Conversation
|
This pull request was exported from Phabricator. Differential Revision: D80705652 |
|
0fa272b to
f5f776e
Compare
…ebook#53397) Summary: This is a runtime behaviour fix and an API change to `Appearance.setColorScheme`, motivated by a user report where providing `'unspecified'` (valid) to this function would trigger an incorrect invariant throw. Furthermore, there is already a [first party use](https://github.com/facebook/react-native/blob/aec35b896053d9372ccdaf67c939b2eb216d3455/packages/react-native/Libraries/Utilities/Appearance.js#L101) where we call `Appearance.setColorScheme('unspecified')`. **Changes** - `Appearance.d.ts` (current public API, manual types): Fix `ColorSchemeName` type to include `'unspecified'` value, and narrow to remove nullability — aligning with existing Flow source for this type in `NativeAppearance`. - `Appearance.js` (implementation): Fix the invariant throw by **removing it**, and instead narrowing the input type to non-nullable. Redundant work in `getState` and `getColorScheme` is removed. Changelog: [General][Breaking] `Appearance.setColorScheme` no longer accepts a nullable value Differential Revision: D80705652
|
This pull request was exported from Phabricator. Differential Revision: D80705652 |
…ebook#53397) Summary: This is a runtime behaviour fix and an API change to `Appearance.setColorScheme`, motivated by a user report where providing `'unspecified'` (valid) to this function would trigger an incorrect invariant throw. Furthermore, there is already a [first party use](https://github.com/facebook/react-native/blob/aec35b896053d9372ccdaf67c939b2eb216d3455/packages/react-native/Libraries/Utilities/Appearance.js#L101) where we call `Appearance.setColorScheme('unspecified')`. **Changes** - `Appearance.d.ts` (current public API, manual types): Fix `ColorSchemeName` type to include `'unspecified'` value, and narrow to remove nullability — aligning with existing Flow source for this type in `NativeAppearance`. - `Appearance.js` (implementation): Fix the invariant throw by **removing it**, and instead narrowing the input type to non-nullable. Redundant work in `getState` and `getColorScheme` is removed. Changelog: [General][Breaking] `Appearance.setColorScheme` no longer accepts a nullable value Reviewed By: andrewdacenko Differential Revision: D80705652
f5f776e to
c5bd7f7
Compare
…ebook#53397) Summary: Pull Request resolved: facebook#53397 This is a runtime behaviour fix and an API change to `Appearance.setColorScheme`, motivated by a user report where providing `'unspecified'` (valid) to this function would trigger an incorrect invariant throw. Furthermore, there is already a [first party use](https://github.com/facebook/react-native/blob/aec35b896053d9372ccdaf67c939b2eb216d3455/packages/react-native/Libraries/Utilities/Appearance.js#L101) where we call `Appearance.setColorScheme('unspecified')`. **Changes** - `Appearance.d.ts` (current public API, manual types): Fix `ColorSchemeName` type to include `'unspecified'` value, and narrow to remove nullability — aligning with existing Flow source for this type in `NativeAppearance`. - `Appearance.js` (implementation): Fix the invariant throw by **removing it**, and instead narrowing the input type to non-nullable. Redundant work in `getState` and `getColorScheme` is removed. Changelog: [General][Breaking] `Appearance.setColorScheme` no longer accepts a nullable value Reviewed By: andrewdacenko Differential Revision: D80705652
|
This pull request was exported from Phabricator. Differential Revision: D80705652 |
c5bd7f7 to
f178018
Compare
|
This pull request has been merged in a4581ec. |
|
This pull request was successfully merged by @huntie in a4581ec When will my fix make it into a release? | How to file a pick request? |
Summary:
This is a runtime behaviour fix and an API change to
Appearance.setColorScheme, motivated by a user report where providing'unspecified'(valid) to this function would trigger an incorrect invariant throw. Furthermore, there is already a first party use where we callAppearance.setColorScheme('unspecified').Changes
Appearance.d.ts(current public API, manual types): FixColorSchemeNametype to include'unspecified'value, and narrow to remove nullability — aligning with existing Flow source for this type inNativeAppearance.Appearance.js(implementation): Fix the invariant throw by removing it, and instead narrowing the input type to non-nullable. Redundant work ingetStateandgetColorSchemeis removed.Changelog: [General][Breaking]
Appearance.setColorSchemeno longer accepts a nullable valueDifferential Revision: D80705652