react / react/react-native

[TypeScript] react-native-strict-api transform can be `undefined`

Open
#53,899 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Author Provided Repro Needs: React Native Team Attention p: Software Mansion Partner
Dominant language
C++
Stars
127k
Forks
25.3k
Avg merge
1d 23h
Merged PRs (30d)
4

Description

Description

While working on the react-native-strict-api support in Reanimated I noticed that the type of the transforms array element changed. Before it could be an object with a single transform property and value. In new types it can be also undefined which doesn't seem to be valid because the transforms array should not contain undefined values.

Steps to reproduce
  1. Enable react-native-strict-api in tsconfig.json
  2. Copy the following code to the app:
const transforms: ViewStyle['transform'] = [];

transforms.forEach(transform => {
  console.log(Object.keys(transform));
});
  1. Observe that TS is complaining about the Object.keys(transform) call and says that transform can be undefined
React Native Version

0.81.4

Affected Platforms

Build - Linux, Build - Windows, Build - MacOS, Runtime - Desktop, Runtime - Web, Runtime - iOS, Runtime - Android

Output of npx @react-native-community/cli info
System:
  OS: macOS 15.6
  CPU: (11) arm64 Apple M3 Pro
  Memory: 152.89 MB / 18.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.14.0
    path: ~/.nvm/versions/node/v22.14.0/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.nvm/versions/node/v22.14.0/bin/yarn
  npm:
    version: 10.9.2
    path: ~/.nvm/versions/node/v22.14.0/bin/npm
  Watchman:
    version: 2025.06.30.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /Users/mateu/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.0
      - iOS 26.0
      - macOS 26.0
      - tvOS 26.0
      - visionOS 26.0
      - watchOS 26.0
  Android SDK:
    API Levels:
      - "30"
      - "33"
      - "34"
      - "35"
      - "36"
    Build Tools:
      - 30.0.3
      - 33.0.1
      - 34.0.0
      - 35.0.0
      - 36.0.0
    System Images:
      - android-34 | Android TV ARM 64 v8a
      - android-35 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2025.1 AI-251.26094.121.2513.14007798
  Xcode:
    version: 26.0/17A324
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.15
    path: /opt/homebrew/opt/openjdk@17/bin/javac
  Ruby:
    version: 3.2.2
    path: /Users/mateu/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.0.0
    wanted: 20.0.0
  react:
    installed: 19.1.0
    wanted: 19.1.0
  react-native:
    installed: 0.81.4
    wanted: 0.81.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: false
Stacktrace or Logs
No overload matches this call.
  Overload 1 of 2, '(o: {}): string[]', gave the following error.
    Argument of type 'Readonly<MaximumOneOf<MergeUnion<{ readonly perspective: number | AnimatedNode; } | { readonly rotate: string | AnimatedNode; } | { readonly rotateX: string | AnimatedNode; } | ... 10 more ... | { ...; }>>>' is not assignable to parameter of type '{}'.
      Type 'undefined' is not assignable to type '{}'.
  Overload 2 of 2, '(o: object): string[]', gave the following error.
    Argument of type 'Readonly<MaximumOneOf<MergeUnion<{ readonly perspective: number | AnimatedNode; } | { readonly rotate: string | AnimatedNode; } | { readonly rotateX: string | AnimatedNode; } | ... 10 more ... | { ...; }>>>' is not assignable to parameter of type 'object'.
      Type 'undefined' is not assignable to type 'object'.
MANDATORY Reproducer

https://github.com/MatiPl01/react-native-strict-api-reproducer/tree/undefined-transforms

Screenshots and Videos
Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the mandatory reproducer and the ViewStyle['transform'] type while using react-native-strict-api in tsconfig.json. Trace the React Native type definition that introduces undefined, then verify that the transforms example accepts Object.keys(transform) without a possibly-undefined error.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, typescript
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.