Skip to content

Convert additional Props/Style types to interface - #58062

Open
huntie wants to merge 1 commit into
react:mainfrom
huntie:fix-definitely-typed-interfaces
Open

Convert additional Props/Style types to interface#58062
huntie wants to merge 1 commit into
react:mainfrom
huntie:fix-definitely-typed-interfaces

Conversation

@huntie

@huntiehuntie commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

In response to this comment: #57490 (comment)

The DefinitelyTyped react-native-web types augment the react-native module to layer web-only props and style values onto React Native's types. Module augmentation only works against interface declarations, so these hit error TS2300: Duplicate identifier.

This was solved in #56809 — this diff extends interface emission to additional types as below.

Changes

Annotate the remaining types that @types/react-native-web augments with @build-types emit-as-interface:

  • AccessibilityProps
  • ImageProps
  • PressableStateCallbackType
  • ViewStyle, TextStyle, ImageStyle

Source for matched @types/react-native-web conflicts

TypeDeclared inAugmented by @types/react-native-web
AccessibilityPropsLibraries/Components/View/ViewAccessibility.js:342index.d.ts#L1272
ImagePropsLibraries/Image/ImageProps.js:336index.d.ts#L1422
PressableStateCallbackTypeLibraries/Components/Pressable/Pressable.js:36index.d.ts#L1444
ViewStyleLibraries/StyleSheet/StyleSheet.js.flow:141index.d.ts#L1458
TextStyleLibraries/StyleSheet/StyleSheet.js.flow:159index.d.ts#L1486
ImageStyleLibraries/StyleSheet/StyleSheet.js.flow:177index.d.ts#L1514

Not fixed

The remaining DT failures (parsed from https://github.com/DefinitelyTyped/DefinitelyTyped/actions/runs/32138113480) aren't interface issues:

  • InteractionManager has no export in the Strict API at all.
  • VirtualizedListProps is genuinely non-generic in the Flow source (packages/virtualized-lists/Lists/VirtualizedListProps.js:287), and getItem / getItemCount are required there. DT's VirtualizedListProps<ItemT> with those omitted is an assumption carried over from the old hand-written types.
  • The ViewStyle / TextStyle / ImageStyle "incorrectly extends WebStyle" errors will persist. RN's DimensionValue includes null, and DT redefines bottom?: CSSProperties["bottom"] | DimensionValue on an interface extending WebStyle, whose bottom does not accept null. DT needs Exclude<DimensionValue, null> there. Expect 3 of the 16 reported errors to remain once the duplicate-identifier ones clear.

cc @jakebailey

Changelog:
[General][Fixed] - JS API: Additional Props/Style types are now defined as interface, fixing compatibility with certain DefinitelyTyped packages

Test Plan

  • node ./scripts/js-api/build-types — snapshot regenerated; --validate passes
  • yarn test-generated-typescript, yarn test-typescript — pass
  • yarn jest scripts/js-api — 141 tests pass
  • Scratch project replaying react-native-web's augmentations against types_generated: all six now merge cleanly. As a control, augmenting ImagePropsAndroid (still a type alias) in the same harness reproduces error TS2300: Duplicate identifier, confirming the harness detects the failure mode.

@meta-clameta-claBot 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 Aug 21, 2026
@github-actions

Copy link
Copy Markdown

Warning

JavaScript API change detected

This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API.

  • Please include a clear changelog message.
  • This change will be subject to additional review.

This change was flagged as: POTENTIALLY_BREAKING

@huntie
huntieforce-pushed the fix-definitely-typed-interfaces branch from c359385 to 57b788fCompareAugust 21, 2026 14:58
@facebook-github-toolsfacebook-github-toolsBot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 21, 2026
@jakebailey

Copy link
Copy Markdown

Do you have any timeline for when you think this (or a similar PR) might be merged and released? The types break is blocking PRs to any react types on DT.

@huntie

Copy link
Copy Markdown
ContributorAuthor

@jakebailey As soon as this gets merged, I'll raise a pick request into the 0.87 branch, then it'll go out in the next patch release (typically Mondays).

cc @zeyap@cortinico

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

Labels

CLA SignedThis label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.Shared with MetaApplied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@huntie@jakebailey