Skip to content

Add TypeScript declaration for the performance global #58610

Description

@johnnycheng0210

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Author FeedbackNeeds: ReproThis issue could be improved with a clear list of steps to reproduce the issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions