Repository navigation
Make legacy TypeScript ImageStyle extend ViewStyle (#58907) - #58907
Closed
ramya-2196 wants to merge 1 commit into
Closed
ramya-2196 wants to merge 1 commit into
ramya-2196 wants to merge 1 commit into
Conversation
|
@ramya-2196 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D123003237. |
ramya-2196
added a commit
to ramya-2196/react-native
that referenced
this pull request
Oct 7, 2026
Summary: ## Motivation Projects on the default legacy TypeScript types get type errors when they set valid style props on `<Image>`. This is coming from [issue](react#52957) ## What is the Issue About? It reports that `filter`, `boxShadow`, `mixBlendMode`, `borderTopStartRadius` and `outlineColor` props give TS error. These props are already accepted by the opt-in strict API types. ## Background React Native ships two sets of TypeScript style types: - **Legacy (default):** hand-written in `types_DEPRECATED/Libraries/StyleSheet/StyleSheetTypes.d.ts`. Maintained by hand, so it drifts. - **Strict API (opt-in):** generated from the Flow source of truth, `Libraries/StyleSheet/StyleSheetTypes.js`, so it cannot drift. ## Root Cause In Flow, `ImageStyle` spreads `ViewStyle` and only narrows `overflow` to `visible | hidden`. The legacy `ImageStyle` instead extended `FlexStyle`/`ShadowStyleIOS`/`TransformsStyle` and redeclared a hand-picked subset of view props, so it rejected 37 `ViewStyle` props: - Border and outline colours: `borderTopColor`, `borderBottomColor`, `borderLeftColor`, `borderRightColor`, `borderStartColor`, `borderEndColor`, `borderBlockColor`, `borderBlockStartColor`, `borderBlockEndColor`, `outlineColor` - Logical corner radii: `borderTopStartRadius`, `borderTopEndRadius`, `borderBottomStartRadius`, `borderBottomEndRadius`, `borderStartStartRadius`, `borderStartEndRadius`, `borderEndStartRadius`, `borderEndEndRadius` - `borderCurve`, `borderStyle`, `outlineStyle`, `outlineWidth`, `outlineOffset`, `elevation`, `pointerEvents`, `isolation`, `boxShadow`, `filter`, `mixBlendMode` - Background layers: `backgroundImage`, `backgroundSize`, `backgroundPosition`, `backgroundRepeat` and their `experimental_` versions `TextStyle` already extends `ViewStyle`, so it is not affected. ## Description of Changes - `ImageStyle` now extends `ViewStyle`, narrows `overflow` to `visible | hidden`, and keeps only the Image-specific props (`resizeMode`, `overlayColor`, `tintColor`, `objectFit`). The 10 view props it used to redeclare are now inherited with identical types. New `ViewStyle` props flow through automatically, as they already do for `TextStyle` and for the generated types. - The type test `__typetests__/stylesheet-style-props.tsx` (renamed from the earlier issue reproducer) sets all 37 props on an Image style. It asserts that `ImageStyle` and `TextStyle` declare every `ViewStyle` key, so future drift fails CI with the missing prop names. Negative checks confirm `ImageStyle` still rejects `overflow: "scroll"` and text-only props. The change only widens what `ImageStyle` accepts, matching the generated types. Changelog: [General][Fixed] - Fix the legacy TypeScript `ImageStyle` type rejecting valid `ViewStyle` props such as `filter`, `boxShadow` and `mixBlendMode` Differential Revision: D123003237
ramya-2196
force-pushed
the
export-D123003237
branch
from
October 7, 2026 13:59
31a3b8e to
3ccf6a0
Compare
Summary: Fixes react#52957 ## Motivation Projects on the default legacy TypeScript types get type errors when they set valid style props on `<Image>`. This is coming from [issue](react#52957) ## What is the Issue About? It reports that `filter`, `boxShadow`, `mixBlendMode`, `borderTopStartRadius` and `outlineColor` props give TS error. These props are already accepted by the opt-in strict API types. ## Background React Native ships two sets of TypeScript style types: - **Legacy (default):** hand-written in `types_DEPRECATED/Libraries/StyleSheet/StyleSheetTypes.d.ts`. Maintained by hand, so it drifts. - **Strict API (opt-in):** generated from the Flow source of truth, `Libraries/StyleSheet/StyleSheetTypes.js`, so it cannot drift. ## Root Cause In Flow, `ImageStyle` spreads `ViewStyle` and only narrows `overflow` to `visible | hidden`. The legacy `ImageStyle` instead extended `FlexStyle`/`ShadowStyleIOS`/`TransformsStyle` and redeclared a hand-picked subset of view props, so it rejected 37 `ViewStyle` props: - Border and outline colours: `borderTopColor`, `borderBottomColor`, `borderLeftColor`, `borderRightColor`, `borderStartColor`, `borderEndColor`, `borderBlockColor`, `borderBlockStartColor`, `borderBlockEndColor`, `outlineColor` - Logical corner radii: `borderTopStartRadius`, `borderTopEndRadius`, `borderBottomStartRadius`, `borderBottomEndRadius`, `borderStartStartRadius`, `borderStartEndRadius`, `borderEndStartRadius`, `borderEndEndRadius` - `borderCurve`, `borderStyle`, `outlineStyle`, `outlineWidth`, `outlineOffset`, `elevation`, `pointerEvents`, `isolation`, `boxShadow`, `filter`, `mixBlendMode` - Background layers: `backgroundImage`, `backgroundSize`, `backgroundPosition`, `backgroundRepeat` and their `experimental_` versions `TextStyle` already extends `ViewStyle`, so it is not affected. ## Description of Changes - `ImageStyle` now extends `ViewStyle`, narrows `overflow` to `visible | hidden`, and keeps only the Image-specific props (`resizeMode`, `overlayColor`, `tintColor`, `objectFit`). The 10 view props it used to redeclare are now inherited with identical types. New `ViewStyle` props flow through automatically, as they already do for `TextStyle` and for the generated types. - The type test `__typetests__/stylesheet-style-props.tsx` (renamed from the earlier issue reproducer) sets all 37 props on an Image style. It asserts that `ImageStyle` and `TextStyle` declare every `ViewStyle` key, so future drift fails CI with the missing prop names. Negative checks confirm `ImageStyle` still rejects `overflow: "scroll"` and text-only props. The change only widens what `ImageStyle` accepts, matching the generated types. Changelog: [General][Fixed] - Fix the legacy TypeScript `ImageStyle` type rejecting valid `ViewStyle` props such as `filter`, `boxShadow` and `mixBlendMode` Reviewed By: vzaidman Differential Revision: D123003237
ramya-2196
force-pushed
the
export-D123003237
branch
from
October 7, 2026 14:36
3ccf6a0 to
7b9255b
Compare
|
This pull request has been merged in 278e7f9. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Fixes #52957
Motivation
Projects on the default legacy TypeScript types get type errors when they set valid style props on
<Image>. This is coming from issueWhat is the Issue About?
It reports that
filter,boxShadow,mixBlendMode,borderTopStartRadiusandoutlineColorprops give TS error. These props are already accepted by the opt-in strict API types.Background
React Native ships two sets of TypeScript style types:
types_DEPRECATED/Libraries/StyleSheet/StyleSheetTypes.d.ts. Maintained by hand, so it drifts.Libraries/StyleSheet/StyleSheetTypes.js, so it cannot drift.Root Cause
In Flow,
ImageStylespreadsViewStyleand only narrowsoverflowtovisible | hidden. The legacyImageStyleinstead extendedFlexStyle/ShadowStyleIOS/TransformsStyleand redeclared a hand-picked subset of view props, so it rejected 37ViewStyleprops:borderTopColor,borderBottomColor,borderLeftColor,borderRightColor,borderStartColor,borderEndColor,borderBlockColor,borderBlockStartColor,borderBlockEndColor,outlineColorborderTopStartRadius,borderTopEndRadius,borderBottomStartRadius,borderBottomEndRadius,borderStartStartRadius,borderStartEndRadius,borderEndStartRadius,borderEndEndRadiusborderCurve,borderStyle,outlineStyle,outlineWidth,outlineOffset,elevation,pointerEvents,isolation,boxShadow,filter,mixBlendModebackgroundImage,backgroundSize,backgroundPosition,backgroundRepeatand theirexperimental_versionsTextStylealready extendsViewStyle, so it is not affected.Description of Changes
ImageStylenow extendsViewStyle, narrowsoverflowtovisible | hidden, and keeps only the Image-specific props (resizeMode,overlayColor,tintColor,objectFit). The 10 view props it used to redeclare are now inherited with identical types. NewViewStyleprops flow through automatically, as they already do forTextStyleand for the generated types.__typetests__/stylesheet-style-props.tsx(renamed from the earlier issue reproducer) sets all 37 props on an Image style. It asserts thatImageStyleandTextStyledeclare everyViewStylekey, so future drift fails CI with the missing prop names. Negative checks confirmImageStylestill rejectsoverflow: "scroll"and text-only props.The change only widens what
ImageStyleaccepts, matching the generated types.Changelog:
[General][Fixed] - Fix the legacy TypeScript
ImageStyletype rejecting validViewStyleprops such asfilter,boxShadowandmixBlendModeReviewed By: vzaidman
Differential Revision: D123003237