Skip to content

Make legacy TypeScript ImageStyle extend ViewStyle (#58907) - #58907

Closed
ramya-2196 wants to merge 1 commit into
react:mainfrom
ramya-2196:export-D123003237
Closed

ramya-2196 wants to merge 1 commit into
react:mainfrom
ramya-2196:export-D123003237

Conversation

@ramya-2196

@ramya-2196 ramya-2196 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

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 issue

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

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 7, 2026
@facebook-github-tools facebook-github-tools Bot added p: Facebook Partner: Facebook Partner labels Oct 7, 2026
@meta-codesync

meta-codesync Bot commented Oct 7, 2026

Copy link
Copy Markdown

@ramya-2196 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D123003237.

@meta-codesync meta-codesync Bot changed the title Make legacy TypeScript ImageStyle extend ViewStyle Make legacy TypeScript ImageStyle extend ViewStyle (#58907) Oct 7, 2026
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
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
@meta-codesync

meta-codesync Bot commented Oct 7, 2026

Copy link
Copy Markdown

This pull request has been merged in 278e7f9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TypeScript] Properties missing in ImageStyle and TextStyle type

1 participant