`requestIdleCallback` is not defined in TS types

Đang mở Phù hợp với người mới
#58,565 1 bình luận 2 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
react-native, typescript
Lĩnh vực
mobile

Hướng nghiên cứu

Bắt đầu với reproducer bắt buộc tại https://github.com/simon-abbott/rn-bug-idle-callback-type-missing và kiểm tra các khai báo TypeScript của React Native 0.87 liên quan đến requestIdleCallback. Issue hoàn tất khi một lệnh gọi requestIdleCallback được kiểm tra kiểu thành công mà không gặp lỗi TS2304.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Needs: Triage :mag:
Description

The v0.87 announcement says that InteractionManager has been removed (https://github.com/react/react-native/pull/57394) and we should use requestIdleCallback instead. The only issue with that is that when I put a call to requestIdleCallback in the code TypeScript spits out the error Cannot find name 'requestIdleCallback'., which means we can't actually use requestIdleCallback without breaking the TypeScript build.

Steps to reproduce
  1. Update to React Native 0.87
  2. Try to call requestIdleCallback
React Native Version

0.87.1

Affected Platforms

Build - MacOS

Output of npx @react-native-community/cli info
info Fetching system and libraries information...
System:
  OS: macOS 26.7
  CPU: (14) arm64 Apple M4 Pro
  Memory: 258.31 MB / 48.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 24.16.0
    path: /Users/<redacted>/.nvm/versions/node/v24.16.0/bin/node
  Yarn:
    version: 1.22.19
    path: /usr/local/bin/yarn
  npm:
    version: 11.13.0
    path: /Users/<redacted>/.nvm/versions/node/v24.16.0/bin/npm
  Watchman:
    version: 2026.07.27.00
    path: /run/current-system/sw/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.5
      - iOS 26.5
      - macOS 26.5
      - tvOS 26.5
      - visionOS 26.5
      - watchOS 26.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2025.1 AI-251.26094.121.2512.13930704
  Xcode:
    version: 26.6/17F113
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.19
    path: /run/current-system/sw/bin/javac
  Ruby:
    version: 2.7.8
    path: /Users/<redacted>/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.2.0
    wanted: 20.2.0
  react:
    installed: 19.2.3
    wanted: 19.2.3
  react-native:
    installed: 0.87.1
    wanted: 0.87.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
Stacktrace or Logs
path/to/problem/file.ts:36:20 - error TS2304: Cannot find name 'requestIdleCallback'.

36       const task = requestIdleCallback(() => {
                      ~~~~~~~~~~~~~~~~~~~
MANDATORY Reproducer

https://github.com/simon-abbott/rn-bug-idle-callback-type-missing

Screenshots and Videos

No response

Ngôn ngữ chính
C++
Star
127k
Fork
25.3k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của react/react-native

Tất cả issue của react/react-native

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.