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 ·