Skip to content

Commit 0592746

Browse files
zeyapmeta-codesync[bot]
authored andcommitted
Make PlatformColor extend NativeColorValue type (facebook#54436)
Summary: Pull Request resolved: facebook#54436 ## Changelog: [Internal] [Changed] - Make PlatformColor extend NativeColorValue type Currently PlatformColor extends ColorValue type which is union of null, number, string, NativeColorValue etc. But it's essentially a NativeColorValue (aka OpaqueColorValue) type on every platform. Here we're typing it more specifically. Reviewed By: javache Differential Revision: D86351282 fbshipit-source-id: 291fee34c97c7ac6ec496f6fcd8e794ee6088f58
1 parent f2898d4 commit 0592746

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

packages/react-native/Libraries/StyleSheet/PlatformColorValueTypes.android.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
*/
1010

1111
import type {ProcessedColorValue} from './processColor';
12-
import type {ColorValue, NativeColorValue} from './StyleSheet';
12+
import type {NativeColorValue} from './StyleSheet';
1313

1414
/** The actual type of the opaque NativeColorValue on Android platform */
1515
type LocalNativeColorValue = {
1616
resource_paths?: Array<string>,
1717
};
1818

19-
export const PlatformColor = (...names: Array<string>): ColorValue => {
19+
export const PlatformColor = (...names: Array<string>): NativeColorValue => {
2020
/* $FlowExpectedError[incompatible-type]
2121
* LocalNativeColorValue is the actual type of the opaque NativeColorValue on Android platform */
2222
return ({resource_paths: names}: LocalNativeColorValue);

packages/react-native/Libraries/StyleSheet/PlatformColorValueTypes.ios.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type LocalNativeColorValue = {
2222
},
2323
};
2424

25-
export const PlatformColor = (...names: Array<string>): ColorValue => {
25+
export const PlatformColor = (...names: Array<string>): NativeColorValue => {
2626
// $FlowExpectedError[incompatible-type] LocalNativeColorValue is the iOS LocalNativeColorValue type
2727
return ({semantic: names}: LocalNativeColorValue);
2828
};

packages/react-native/Libraries/StyleSheet/PlatformColorValueTypes.js.flow

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
*/
1010

1111
import type {ProcessedColorValue} from './processColor';
12-
import type {ColorValue, NativeColorValue} from './StyleSheet';
12+
import type {NativeColorValue} from './StyleSheet';
1313

14-
declare export function PlatformColor(...names: Array<string>): ColorValue;
14+
declare export function PlatformColor(
15+
...names: Array<string>
16+
): NativeColorValue;
1517

1618
declare export function normalizeColorObject(
1719
color: NativeColorValue,

packages/react-native/ReactNativeApi.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<a01aee11d06658fe06d702ee4c48bf8e>>
7+
* @generated SignedSource<<1eb51bd683ea578d108218d5a48c42ec>>
88
*
99
* This file was generated by scripts/js-api/build-types/index.js.
1010
*/
@@ -3669,7 +3669,7 @@ declare class PixelRatio {
36693669
static startDetecting(): void
36703670
}
36713671
declare type Platform = typeof Platform
3672-
declare function PlatformColor(...names: Array<string>): ColorValue
3672+
declare function PlatformColor(...names: Array<string>): NativeColorValue
36733673
declare type PlatformConfig = {}
36743674
declare type PlatformOSType =
36753675
| "android"
@@ -6080,7 +6080,7 @@ export {
60806080
PermissionsAndroid, // 0c1619e7
60816081
PixelRatio, // 10d9e32d
60826082
Platform, // dc0f5740
6083-
PlatformColor, // be964947
6083+
PlatformColor, // 8297ec62
60846084
PlatformOSType, // 0a17561e
60856085
PlatformSelectSpec, // 09ed7758
60866086
PointValue, // 69db075f

0 commit comments

Comments
 (0)