summaryrefslogtreecommitdiff
path: root/cli/tsc/dts/lib.deno.shared_globals.d.ts
diff options
context:
space:
mode:
authorud2 <sjx233@qq.com>2023-07-04 02:36:55 +0800
committerGitHub <noreply@github.com>2023-07-03 14:36:55 -0400
commitd632cce129cb7025a34cf0aa7262a38fb12f47c4 (patch)
tree6fe672badbe6ea0fb8a30ecc88b74c613aaa7370 /cli/tsc/dts/lib.deno.shared_globals.d.ts
parente8a866ca8a682b552722926161a7816c5cf94124 (diff)
fix(dts): make globals available on globalThis (#19438)
This PR changes Web IDL interfaces to be declared with `var` instead of `class`, so that accessing them via `globalThis` does not raise type errors. Closes #13390.
Diffstat (limited to 'cli/tsc/dts/lib.deno.shared_globals.d.ts')
-rw-r--r--cli/tsc/dts/lib.deno.shared_globals.d.ts112
1 files changed, 86 insertions, 26 deletions
diff --git a/cli/tsc/dts/lib.deno.shared_globals.d.ts b/cli/tsc/dts/lib.deno.shared_globals.d.ts
index d11e2933b..49b6f7956 100644
--- a/cli/tsc/dts/lib.deno.shared_globals.d.ts
+++ b/cli/tsc/dts/lib.deno.shared_globals.d.ts
@@ -410,7 +410,7 @@ declare function clearInterval(id?: number): void;
declare function clearTimeout(id?: number): void;
/** @category Scheduling */
-interface VoidFunction {
+declare interface VoidFunction {
(): void;
}
@@ -442,7 +442,7 @@ declare function queueMicrotask(func: VoidFunction): void;
declare function dispatchEvent(event: Event): boolean;
/** @category DOM APIs */
-interface DOMStringList {
+declare interface DOMStringList {
/** Returns the number of strings in strings. */
readonly length: number;
/** Returns true if strings contains string, and false otherwise. */
@@ -453,13 +453,13 @@ interface DOMStringList {
}
/** @category Typed Arrays */
-type BufferSource = ArrayBufferView | ArrayBuffer;
+declare type BufferSource = ArrayBufferView | ArrayBuffer;
/** @category Console and Debugging */
declare var console: Console;
/** @category DOM Events */
-interface ErrorEventInit extends EventInit {
+declare interface ErrorEventInit extends EventInit {
message?: string;
filename?: string;
lineno?: number;
@@ -468,54 +468,63 @@ interface ErrorEventInit extends EventInit {
}
/** @category DOM Events */
-declare class ErrorEvent extends Event {
+declare interface ErrorEvent extends Event {
readonly message: string;
readonly filename: string;
readonly lineno: number;
readonly colno: number;
readonly error: any;
- constructor(type: string, eventInitDict?: ErrorEventInit);
}
+/** @category DOM Events */
+declare var ErrorEvent: {
+ readonly prototype: ErrorEvent;
+ new (type: string, eventInitDict?: ErrorEventInit): ErrorEvent;
+};
+
/** @category Observability */
-interface PromiseRejectionEventInit extends EventInit {
+declare interface PromiseRejectionEventInit extends EventInit {
promise: Promise<any>;
reason?: any;
}
/** @category Observability */
-declare class PromiseRejectionEvent extends Event {
+declare interface PromiseRejectionEvent extends Event {
readonly promise: Promise<any>;
readonly reason: any;
- constructor(type: string, eventInitDict?: PromiseRejectionEventInit);
}
+/** @category Observability */
+declare var PromiseRejectionEvent: {
+ readonly prototype: PromiseRejectionEvent;
+ new (
+ type: string,
+ eventInitDict?: PromiseRejectionEventInit,
+ ): PromiseRejectionEvent;
+};
+
/** @category Web Workers */
-interface AbstractWorkerEventMap {
+declare interface AbstractWorkerEventMap {
"error": ErrorEvent;
}
/** @category Web Workers */
-interface WorkerEventMap extends AbstractWorkerEventMap {
+declare interface WorkerEventMap extends AbstractWorkerEventMap {
"message": MessageEvent;
"messageerror": MessageEvent;
}
/** @category Web Workers */
-interface WorkerOptions {
+declare interface WorkerOptions {
type?: "classic" | "module";
name?: string;
}
/** @category Web Workers */
-declare class Worker extends EventTarget {
+declare interface Worker extends EventTarget {
onerror?: (e: ErrorEvent) => void;
onmessage?: (e: MessageEvent) => void;
onmessageerror?: (e: MessageEvent) => void;
- constructor(
- specifier: string | URL,
- options?: WorkerOptions,
- );
postMessage(message: any, transfer: Transferable[]): void;
postMessage(message: any, options?: StructuredSerializeOptions): void;
addEventListener<K extends keyof WorkerEventMap>(
@@ -541,14 +550,19 @@ declare class Worker extends EventTarget {
terminate(): void;
}
+/** @category Web Workers */
+declare var Worker: {
+ readonly prototype: Worker;
+ new (specifier: string | URL, options?: WorkerOptions): Worker;
+};
+
/** @category Performance */
declare type PerformanceEntryList = PerformanceEntry[];
/** @category Performance */
-declare class Performance extends EventTarget {
+declare interface Performance extends EventTarget {
/** Returns a timestamp representing the start of the performance measurement. */
readonly timeOrigin: number;
- constructor();
/** Removes the stored timestamp with the associated name. */
clearMarks(markName?: string): void;
@@ -595,6 +609,12 @@ declare class Performance extends EventTarget {
}
/** @category Performance */
+declare var Performance: {
+ readonly prototype: Performance;
+ new (): never;
+};
+
+/** @category Performance */
declare var performance: Performance;
/** @category Performance */
@@ -628,7 +648,7 @@ declare interface PerformanceMeasureOptions {
*
* @category Performance
*/
-declare class PerformanceEntry {
+declare interface PerformanceEntry {
readonly duration: number;
readonly entryType: string;
readonly name: string;
@@ -636,6 +656,18 @@ declare class PerformanceEntry {
toJSON(): any;
}
+/** Encapsulates a single performance metric that is part of the performance
+ * timeline. A performance entry can be directly created by making a performance
+ * mark or measure (for example by calling the `.mark()` method) at an explicit
+ * point in an application.
+ *
+ * @category Performance
+ */
+declare var PerformanceEntry: {
+ readonly prototype: PerformanceEntry;
+ new (): never;
+};
+
/** `PerformanceMark` is an abstract interface for `PerformanceEntry` objects
* with an entryType of `"mark"`. Entries of this type are created by calling
* `performance.mark()` to add a named `DOMHighResTimeStamp` (the mark) to the
@@ -643,12 +675,23 @@ declare class PerformanceEntry {
*
* @category Performance
*/
-declare class PerformanceMark extends PerformanceEntry {
+declare interface PerformanceMark extends PerformanceEntry {
readonly detail: any;
readonly entryType: "mark";
- constructor(name: string, options?: PerformanceMarkOptions);
}
+/** `PerformanceMark` is an abstract interface for `PerformanceEntry` objects
+ * with an entryType of `"mark"`. Entries of this type are created by calling
+ * `performance.mark()` to add a named `DOMHighResTimeStamp` (the mark) to the
+ * performance timeline.
+ *
+ * @category Performance
+ */
+declare var PerformanceMark: {
+ readonly prototype: PerformanceMark;
+ new (name: string, options?: PerformanceMarkOptions): PerformanceMark;
+};
+
/** `PerformanceMeasure` is an abstract interface for `PerformanceEntry` objects
* with an entryType of `"measure"`. Entries of this type are created by calling
* `performance.measure()` to add a named `DOMHighResTimeStamp` (the measure)
@@ -656,26 +699,43 @@ declare class PerformanceMark extends PerformanceEntry {
*
* @category Performance
*/
-declare class PerformanceMeasure extends PerformanceEntry {
+declare interface PerformanceMeasure extends PerformanceEntry {
readonly detail: any;
readonly entryType: "measure";
}
+/** `PerformanceMeasure` is an abstract interface for `PerformanceEntry` objects
+ * with an entryType of `"measure"`. Entries of this type are created by calling
+ * `performance.measure()` to add a named `DOMHighResTimeStamp` (the measure)
+ * between two marks to the performance timeline.
+ *
+ * @category Performance
+ */
+declare var PerformanceMeasure: {
+ readonly prototype: PerformanceMeasure;
+ new (): never;
+};
+
/** @category DOM Events */
declare interface CustomEventInit<T = any> extends EventInit {
detail?: T;
}
/** @category DOM Events */
-declare class CustomEvent<T = any> extends Event {
- constructor(typeArg: string, eventInitDict?: CustomEventInit<T>);
+declare interface CustomEvent<T = any> extends Event {
/** Returns any custom data event was created with. Typically used for
* synthetic events. */
readonly detail: T;
}
+/** @category DOM Events */
+declare var CustomEvent: {
+ readonly prototype: CustomEvent;
+ new <T>(typeArg: string, eventInitDict?: CustomEventInit<T>): CustomEvent<T>;
+};
+
/** @category DOM APIs */
-interface ErrorConstructor {
+declare interface ErrorConstructor {
/** See https://v8.dev/docs/stack-trace-api#stack-trace-collection-for-custom-exceptions. */
captureStackTrace(error: Object, constructor?: Function): void;
// TODO(nayeemrmn): Support `Error.prepareStackTrace()`. We currently use this