Skip to content

fix(lib): add PerformanceObserver and PerformanceObserverEntryList types#35640

Open
bartlomieju wants to merge 1 commit into
mainfrom
feat/perf-observer-types
Open

fix(lib): add PerformanceObserver and PerformanceObserverEntryList types#35640
bartlomieju wants to merge 1 commit into
mainfrom
feat/perf-observer-types

Conversation

@bartlomieju

@bartlomieju bartlomieju commented Jun 30, 2026

Copy link
Copy Markdown
Member

PerformanceObserver and PerformanceObserverEntryList exist at runtime in
Deno but were never declared in the default libs — only lib.webworker.d.ts
declares them, and the deno.window lib doesn't load it. As a result:

const obs = new PerformanceObserver(
  (list: PerformanceObserverEntryList) => { // TS2749 before this change
    for (const e of list.getEntries()) console.log(e.name);
  },
);
obs.observe({ entryTypes: ["measure"] });

PerformanceObserverEntryList used as a type errored with TS2749
("'PerformanceObserverEntryList' refers to a value, but is being used as a type
here"), even though the value exists at runtime.

This adds the PerformanceObserver, PerformanceObserverEntryList, and
PerformanceObserverCallback declarations to lib.deno.shared_globals.d.ts
next to the existing Performance / PerformanceEntry / PerformanceMark /
PerformanceMeasure ones, so both are usable as values and types in Deno code.


Part of the broader effort to drop Deno's forked TypeScript; see #35621 for context and the overall plan.

PerformanceObserver and PerformanceObserverEntryList exist at runtime but were
not declared in Deno's default libs (only lib.webworker has them, which the
deno.window lib does not load). As a result, using PerformanceObserverEntryList
as a type errored with TS2749 ('refers to a value, but is being used as a type')
and PerformanceObserver had no proper type. Add the interfaces + constructors to
lib.deno.shared_globals alongside the existing Performance* declarations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant