Add TypeScript declaration for the performance global

Open Beginner friendly
#58,610 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
react-native, typescript
Domain
mobile-dev

Research direction

Start with src/types/globals.d.ts and compare its declarations with src/private/webapis/performance/Performance.js and the global setup in Libraries/Core/setUpPerformance.js. Verify the reported tsconfig and sample TypeScript file, then confirm that the performance global and Performance type expose the listed API without TypeScript errors.

Written by the indexing model from the issue text.

Description

Needs: Author Feedback Needs: Repro
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

Dominant language
C++
Stars
127k
Forks
25.3k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from react/react-native

All issues in react/react-native

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.