diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheet.js b/packages/react-native/Libraries/StyleSheet/StyleSheet.js index 39f4a95825e8..b9227c33e11e 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheet.js +++ b/packages/react-native/Libraries/StyleSheet/StyleSheet.js @@ -15,6 +15,7 @@ import type { ____ColorValue_Internal, ____DangerouslyImpreciseStyle_Internal, ____DangerouslyImpreciseStyleProp_Internal, + ____FontVariant_Internal, ____ImageStyle_Internal, ____ImageStyleProp_Internal, ____TextStyle_Internal, @@ -22,12 +23,17 @@ import type { ____TransformStyle_Internal, ____ViewStyle_Internal, ____ViewStyleProp_Internal, + NativeColorValue, } from './StyleSheetTypes'; const StyleSheet: StyleSheetExports = ( require('./StyleSheetExports') as $FlowFixMe ).default; -export type {NativeColorValue} from './StyleSheetTypes'; +export type { + BoxShadowValue, + NativeColorValue, + FilterFunction, +} from './StyleSheetTypes'; /** * This type should be used as the type for anything that is a color. It is @@ -38,10 +44,21 @@ export type {NativeColorValue} from './StyleSheetTypes'; */ export type ColorValue = ____ColorValue_Internal; +/** + * Expose the opaque type for NativeColorValue. + * @deprecated Use NativeColorValue instead. + */ +export type OpaqueColorValue = NativeColorValue; + /** * This type is an object of the properties related to transforms. */ -export type TransformStyle = ____TransformStyle_Internal; +export type TransformsStyle = ____TransformStyle_Internal; + +/** + * This type holds possible values for the `fontVariant` style property. + */ +export type FontVariant = ____FontVariant_Internal; /** * This type should be used as the type for a prop that is passed through diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow b/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow index 857c289d1115..dc213592f72b 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow +++ b/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow @@ -14,6 +14,7 @@ import type { ____ColorValue_Internal, ____DangerouslyImpreciseStyle_Internal, ____DangerouslyImpreciseStyleProp_Internal, + ____FontVariant_Internal, ____ImageStyle_Internal, ____ImageStyleProp_Internal, ____TextStyle_Internal, @@ -21,9 +22,14 @@ import type { ____TransformStyle_Internal, ____ViewStyle_Internal, ____ViewStyleProp_Internal, + NativeColorValue, } from './StyleSheetTypes'; -export type {StyleProp} from './StyleSheetTypes'; +export type { + StyleProp, + BoxShadowValue, + FilterFunction, +} from './StyleSheetTypes'; export type StyleSheetProperties = { hairlineWidth: number, @@ -41,10 +47,20 @@ export type {NativeColorValue} from './StyleSheetTypes'; */ export type ColorValue = ____ColorValue_Internal; +/** + * Expose the opaque type for NativeColorValue. + */ +export type OpaqueColorValue = NativeColorValue; + /** * This type is an object of the properties related to transforms. */ -export type TransformStyle = ____TransformStyle_Internal; +export type TransformsStyle = ____TransformStyle_Internal; + +/** + * This type holds possible values for the `fontVariant` style property. + */ +export type FontVariant = ____FontVariant_Internal; /** * This type should be used as the type for a prop that is passed through diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js index 4490064a9423..20b4b5a4953e 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js +++ b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js @@ -873,7 +873,7 @@ export type ____FontWeight_Internal = | 'heavy' | 'black'; -export type ____FontVariantArray_Internal = $ReadOnlyArray< +export type ____FontVariant_Internal = | 'small-caps' | 'oldstyle-nums' | 'lining-nums' @@ -906,8 +906,10 @@ export type ____FontVariantArray_Internal = $ReadOnlyArray< | 'stylistic-seventeen' | 'stylistic-eighteen' | 'stylistic-nineteen' - | 'stylistic-twenty', ->; + | 'stylistic-twenty'; + +export type ____FontVariantArray_Internal = + $ReadOnlyArray<____FontVariant_Internal>; type ____TextStyle_InternalBase = $ReadOnly<{ color?: ____ColorValue_Internal, diff --git a/packages/react-native/Libraries/StyleSheet/private/_TransformStyle.js b/packages/react-native/Libraries/StyleSheet/private/_TransformStyle.js index 2485acefddba..74aecb7decd0 100644 --- a/packages/react-native/Libraries/StyleSheet/private/_TransformStyle.js +++ b/packages/react-native/Libraries/StyleSheet/private/_TransformStyle.js @@ -37,11 +37,11 @@ export type ____TransformStyle_Internal = $ReadOnly<{ | {+scale: number | AnimatedNode} | {+scaleX: number | AnimatedNode} | {+scaleY: number | AnimatedNode} - | {+translateX: number | AnimatedNode} - | {+translateY: number | AnimatedNode} + | {+translateX: number | string | AnimatedNode} + | {+translateY: number | string | AnimatedNode} | { +translate: - | [number | AnimatedNode, number | AnimatedNode] + | [number | string | AnimatedNode, number | string | AnimatedNode] | AnimatedNode, } | {+skewX: string | AnimatedNode} diff --git a/packages/react-native/Libraries/Utilities/PlatformTypes.js b/packages/react-native/Libraries/Utilities/PlatformTypes.js index d07a09b7ea84..e5f90cfe4985 100644 --- a/packages/react-native/Libraries/Utilities/PlatformTypes.js +++ b/packages/react-native/Libraries/Utilities/PlatformTypes.js @@ -16,11 +16,17 @@ export type PlatformOSType = | 'web' | 'native'; -export type PlatformSelectSpec = { - default?: T, - [PlatformOSType]: T, +type OptionalPlatformSelectSpec = { + [_key in PlatformOSType]?: T, }; +export type PlatformSelectSpec = + | { + ...OptionalPlatformSelectSpec, + default: T, + } + | OptionalPlatformSelectSpec; + type IOSPlatform = { __constants: null, OS: 'ios', diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index 2f48c75eb0da..4440058af04c 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -7370,9 +7370,15 @@ declare export function normalizeRect(rectOrSize: ?RectOrSize): ?Rect; exports[`public API should not change unintentionally Libraries/StyleSheet/StyleSheet.js 1`] = ` "declare const StyleSheet: StyleSheetExports; -export type { NativeColorValue } from \\"./StyleSheetTypes\\"; +export type { + BoxShadowValue, + NativeColorValue, + FilterFunction, +} from \\"./StyleSheetTypes\\"; export type ColorValue = ____ColorValue_Internal; -export type TransformStyle = ____TransformStyle_Internal; +export type OpaqueColorValue = NativeColorValue; +export type TransformsStyle = ____TransformStyle_Internal; +export type FontVariant = ____FontVariant_Internal; export type ViewStyleProp = ____ViewStyleProp_Internal; export type TextStyleProp = ____TextStyleProp_Internal; export type ImageStyleProp = ____ImageStyleProp_Internal; @@ -7391,14 +7397,20 @@ declare export default typeof StyleSheet; exports[`public API should not change unintentionally Libraries/StyleSheet/StyleSheet.js.flow 1`] = ` "export * as default from \\"./StyleSheetExports\\"; -export type { StyleProp } from \\"./StyleSheetTypes\\"; +export type { + StyleProp, + BoxShadowValue, + FilterFunction, +} from \\"./StyleSheetTypes\\"; export type StyleSheetProperties = { hairlineWidth: number, flatten(style: T): T, }; export type { NativeColorValue } from \\"./StyleSheetTypes\\"; export type ColorValue = ____ColorValue_Internal; -export type TransformStyle = ____TransformStyle_Internal; +export type OpaqueColorValue = NativeColorValue; +export type TransformsStyle = ____TransformStyle_Internal; +export type FontVariant = ____FontVariant_Internal; export type ViewStyleProp = ____ViewStyleProp_Internal; export type TextStyleProp = ____TextStyleProp_Internal; export type ImageStyleProp = ____ImageStyleProp_Internal; @@ -7741,7 +7753,7 @@ export type ____FontWeight_Internal = | \\"condensed\\" | \\"heavy\\" | \\"black\\"; -export type ____FontVariantArray_Internal = $ReadOnlyArray< +export type ____FontVariant_Internal = | \\"small-caps\\" | \\"oldstyle-nums\\" | \\"lining-nums\\" @@ -7774,8 +7786,9 @@ export type ____FontVariantArray_Internal = $ReadOnlyArray< | \\"stylistic-seventeen\\" | \\"stylistic-eighteen\\" | \\"stylistic-nineteen\\" - | \\"stylistic-twenty\\", ->; + | \\"stylistic-twenty\\"; +export type ____FontVariantArray_Internal = + $ReadOnlyArray<____FontVariant_Internal>; type ____TextStyle_InternalBase = $ReadOnly<{ color?: ____ColorValue_Internal, fontFamily?: string, @@ -7918,11 +7931,11 @@ exports[`public API should not change unintentionally Libraries/StyleSheet/priva | { +scale: number | AnimatedNode } | { +scaleX: number | AnimatedNode } | { +scaleY: number | AnimatedNode } - | { +translateX: number | AnimatedNode } - | { +translateY: number | AnimatedNode } + | { +translateX: number | string | AnimatedNode } + | { +translateY: number | string | AnimatedNode } | { +translate: - | [number | AnimatedNode, number | AnimatedNode] + | [number | string | AnimatedNode, number | string | AnimatedNode] | AnimatedNode, } | { +skewX: string | AnimatedNode } @@ -8676,10 +8689,15 @@ exports[`public API should not change unintentionally Libraries/Utilities/Platfo | \\"windows\\" | \\"web\\" | \\"native\\"; -export type PlatformSelectSpec = { - default?: T, - [PlatformOSType]: T, +type OptionalPlatformSelectSpec = { + [_key in PlatformOSType]?: T, }; +export type PlatformSelectSpec = + | { + ...OptionalPlatformSelectSpec, + default: T, + } + | OptionalPlatformSelectSpec; type IOSPlatform = { OS: \\"ios\\", get Version(): string,