react / react/react-native

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

オープン
#53,899 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Issue: Author Provided Repro Needs: React Native Team Attention p: Software Mansion Partner
主要言語
C++
スター
127k
フォーク
25.3k
平均マージ
1日 23時間
マージ済み PR(30日)
4

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

tsconfig.json で react-native-strict-api を使用しながら、必須の再現コードと ViewStyle['transform'] 型から始めます。undefined を導入している React Native の型定義を追跡し、その後、transforms の例が possibly-undefined エラーなしで Object.keys(transform) を受け入れることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
react-native, typescript
領域
mobile
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
55/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。