Add TypeScript declaration for the performance global
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 85/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- react-native, typescript
- 领域
- mobile-dev
调研方向
从 src/types/globals.d.ts 开始,将其中的声明与 src/private/webapis/performance/Performance.js 以及 Libraries/Core/setUpPerformance.js 中的全局设置进行比较。验证报告中的 tsconfig 和示例 TypeScript 文件,然后确认全局 performance 和 Performance 类型能够在没有 TypeScript 错误的情况下公开列出的 API。
由索引模型根据 Issue 内容生成。
描述
Description
Hey! React Native installs a performance global on every app, but its TypeScript types do not declare it.
- Libraries/Core/setUpPerformance.js installs the global. It uses setUpPerformanceModern() when NativePerformance exists, and a fallback with only performance.now() otherwise.
- src/private/webapis/performance/Performance.js is the implementation: now, timeOrigin, mark, measure, clearMarks, clearMeasures, getEntries, getEntriesByType, getEntriesByName, memory, eventCounts, rnStartupTiming.
- src/types/globals.d.ts declares neither performance nor Performance. No other .d.ts in the package does.
This is the same gap as #56325 (TextEncoder / TextDecoder).
Happy to submit a PR if that helps
Steps to reproduce
tsconfig.json
{ "compilerOptions": { "lib": ["es2022"], "types": ["react-native"], "strict": true, "noEmit": true } }
.ts file
const start = performance.now();
const p: Performance = performance;
error
error TS2304: Cannot find name 'performance'.
error TS2304: Cannot find name 'Performance'.
React Native Version
0.85.3
Affected Platforms
Other (please specify)
Output of npx @react-native-community/cli info
this is just adding ts declarations
Stacktrace or Logs
this is just adding ts declarations
MANDATORY Reproducer
this is just adding ts declarations
Screenshots and Videos
No response
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.3k
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
react/react-native 的其他 Issue
-
Needs: Author Feedback Needs: Repro
难度 1/5 1 小时以内 新手友好度 92/100
react/react-native#58621 · 1 条评论 ·
-
Needs: Triage :mag:
难度 2/5 1-3 小时 新手友好度 82/100
react/react-native#58565 · 1 条评论 · 2 个 reaction ·
-
Needs: Author Feedback Needs: Repro
难度 2/5 1-3 小时 新手友好度 88/100
react/react-native#58555 · 4 条评论 · 1 个 reaction ·
-
Needs: Attention Needs: Repro
难度 2/5 1-3 小时 新手友好度 85/100
react/react-native#58526 · 2 条评论 ·
-
Needs: Author Feedback Needs: Repro
难度 2/5 1-3 小时 新手友好度 85/100
react/react-native#58448 · 1 条评论 ·
查看 react/react-native 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 90/100
AXERA-TECH/ax-llm#77 ·
-
难度 1/5 1 小时以内 新手友好度 90/100
games-on-whales/wolf#509 ·
-
难度 2/5 1-3 小时 新手友好度 74/100
-
bug-unconfirmed
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 2/5 1-3 小时 新手友好度 74/100
NVIDIA/cuda-samples#453 ·