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

  1. react-native-bot commented on Sep 21, 2026

    @react-native-bot
    Collaborator

    Warning

    Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:


    You can read more about about it on our website: How to report a bug.

  2. johnnycheng0210 commented on Oct 1, 2026

    @johnnycheng0210
    Author

    I've also found that queueMicrotask is also missing TS declarations as well. See here

    export default function queueMicrotask(callback: () => unknown) {

    We currently declare it ourself like this

    declare global {
      function queueMicrotask(callback: () => void): void;
    }
    
  3. johnnycheng0210 commented on Oct 1, 2026

    @johnnycheng0210
    Author

    atob and btoa are also missing ts declarations. See here https://github.com/facebook/hermes/blob/6e2181b288b0306d8bd1988d38d32aa879b745d5/lib/VM/JSLib/GlobalObject.cpp#L768-L771

    We currently declare it ourself like this

    declare global {
      function atob(data: string): string;
      function btoa(data: string): string;
    }
    
  4. Cedric921 commented on Oct 4, 2026

    @Cedric921

    Thanks for the detailed write-up @johnnycheng0210! Since there hadn't been activity for a couple of weeks, I opened #58831, which adds declarations for performance / Performance / PerformanceEntry / PerformanceMark / PerformanceMeasure along with type tests. Sorry if you were already working on it, and your review there would be very welcome.

    I kept that PR scoped to performance. The queueMicrotask, atob and btoa gaps you mentioned aren't covered yet, so they're still open for a follow-up.

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: AttentionIssues where the author has responded to feedback.Needs: 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