`requestIdleCallback` is not defined in TS types
还没有人认领这个 Issue。
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.3k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 4
描述
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
- Update to React Native 0.87
- 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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 https://github.com/simon-abbott/rn-bug-idle-callback-type-missing 中的必需复现程序开始,并检查与 requestIdleCallback 相关的 React Native 0.87 TypeScript 声明。当 requestIdleCallback 调用能够成功通过类型检查且不再出现 TS2304 错误时,该 issue 即完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- react-native, typescript
- 领域
- mobile
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 活跃
- 描述清晰度
- 描述清楚
- 新手友好度
- 82/100