diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.d.ts b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.d.ts index 75f625250c9b7c..7956766b34367a 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.d.ts +++ b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.d.ts @@ -173,23 +173,27 @@ interface MatrixTransform { matrix: AnimatableNumericValue[]; } +type MaximumOneOf = K extends keyof T + ? {[P in K]: T[K]} & {[P in Exclude]?: never} + : never; + export interface TransformsStyle { transform?: - | ( - | PerpectiveTransform - | RotateTransform - | RotateXTransform - | RotateYTransform - | RotateZTransform - | ScaleTransform - | ScaleXTransform - | ScaleYTransform - | TranslateXTransform - | TranslateYTransform - | SkewXTransform - | SkewYTransform - | MatrixTransform - )[] + | MaximumOneOf< + PerpectiveTransform & + RotateTransform & + RotateXTransform & + RotateYTransform & + RotateZTransform & + ScaleTransform & + ScaleXTransform & + ScaleYTransform & + TranslateXTransform & + TranslateYTransform & + SkewXTransform & + SkewYTransform & + MatrixTransform + >[] | string | undefined; /** diff --git a/packages/react-native/types/__typetests__/animated.tsx b/packages/react-native/types/__typetests__/animated.tsx index bee061fb72d2e9..7bee861b77cf0f 100644 --- a/packages/react-native/types/__typetests__/animated.tsx +++ b/packages/react-native/types/__typetests__/animated.tsx @@ -237,6 +237,8 @@ function TestAnimatedAPI() { }} /> ; + {/* @ts-expect-error the transform object must contain only one key-value pair */} + ; ); }