Skip to content

Commit f96dc0a

Browse files
saschanazsandersn
authored andcommitted
Use globalThis for .window/.self (#715)
1 parent ab8f9e5 commit f96dc0a

File tree

4 files changed

+24
-44
lines changed

4 files changed

+24
-44
lines changed

baselines/dom.generated.d.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18478,11 +18478,6 @@ interface WindowEventMap extends GlobalEventHandlersEventMap, WindowEventHandler
1847818478

1847918479
/** A window containing a DOM document; the document property points to the DOM document loaded in that window. */
1848018480
interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, AnimationFrameProvider, WindowOrWorkerGlobalScope, WindowEventHandlers {
18481-
Blob: typeof Blob;
18482-
TextDecoder: typeof TextDecoder;
18483-
TextEncoder: typeof TextEncoder;
18484-
URL: typeof URL;
18485-
URLSearchParams: typeof URLSearchParams;
1848618481
readonly applicationCache: ApplicationCache;
1848718482
readonly caches: CacheStorage;
1848818483
readonly clientInformation: Navigator;
@@ -18562,14 +18557,14 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
1856218557
readonly scrollX: number;
1856318558
readonly scrollY: number;
1856418559
readonly scrollbars: BarProp;
18565-
readonly self: Window;
18560+
readonly self: Window & typeof globalThis;
1856618561
readonly speechSynthesis: SpeechSynthesis;
1856718562
status: string;
1856818563
readonly statusbar: BarProp;
1856918564
readonly styleMedia: StyleMedia;
1857018565
readonly toolbar: BarProp;
1857118566
readonly top: Window;
18572-
readonly window: Window;
18567+
readonly window: Window & typeof globalThis;
1857318568
alert(message?: any): void;
1857418569
blur(): void;
1857518570
/** @deprecated */
@@ -19472,11 +19467,6 @@ declare var Image: {
1947219467
declare var Option: {
1947319468
new(text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement;
1947419469
};
19475-
declare var Blob: typeof Blob;
19476-
declare var TextDecoder: typeof TextDecoder;
19477-
declare var TextEncoder: typeof TextEncoder;
19478-
declare var URL: typeof URL;
19479-
declare var URLSearchParams: typeof URLSearchParams;
1948019470
declare var applicationCache: ApplicationCache;
1948119471
declare var caches: CacheStorage;
1948219472
declare var clientInformation: Navigator;
@@ -19556,14 +19546,14 @@ declare var screenY: number;
1955619546
declare var scrollX: number;
1955719547
declare var scrollY: number;
1955819548
declare var scrollbars: BarProp;
19559-
declare var self: Window;
19549+
declare var self: Window & typeof globalThis;
1956019550
declare var speechSynthesis: SpeechSynthesis;
1956119551
declare var status: string;
1956219552
declare var statusbar: BarProp;
1956319553
declare var styleMedia: StyleMedia;
1956419554
declare var toolbar: BarProp;
1956519555
declare var top: Window;
19566-
declare var window: Window;
19556+
declare var window: Window & typeof globalThis;
1956719557
declare function alert(message?: any): void;
1956819558
declare function blur(): void;
1956919559
/** @deprecated */

baselines/webworker.generated.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5361,7 +5361,7 @@ interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, Win
53615361
readonly location: WorkerLocation;
53625362
onerror: ((this: WorkerGlobalScope, ev: ErrorEvent) => any) | null;
53635363
readonly performance: Performance;
5364-
readonly self: WorkerGlobalScope;
5364+
readonly self: WorkerGlobalScope & typeof globalThis;
53655365
msWriteProfilerMark(profilerMarkName: string): void;
53665366
addEventListener<K extends keyof WorkerGlobalScopeEventMap>(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
53675367
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
@@ -5750,7 +5750,7 @@ declare var isSecureContext: boolean;
57505750
declare var location: WorkerLocation;
57515751
declare var onerror: ((this: DedicatedWorkerGlobalScope, ev: ErrorEvent) => any) | null;
57525752
declare var performance: Performance;
5753-
declare var self: WorkerGlobalScope;
5753+
declare var self: WorkerGlobalScope & typeof globalThis;
57545754
declare function msWriteProfilerMark(profilerMarkName: string): void;
57555755
/**
57565756
* Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.

inputfiles/addedTypes.json

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -532,34 +532,9 @@
532532
"name": "Window",
533533
"properties": {
534534
"property": {
535-
"URL": {
536-
"exposeGlobally": false,
537-
"name": "URL",
538-
"override-type": "typeof URL"
539-
},
540-
"URLSearchParams": {
541-
"exposeGlobally": false,
542-
"name": "URLSearchParams",
543-
"override-type": "typeof URLSearchParams"
544-
},
545-
"Blob": {
546-
"exposeGlobally": false,
547-
"name": "Blob",
548-
"override-type": "typeof Blob"
549-
},
550535
"customElements": {
551536
"name": "customElements",
552-
"override-type": "CustomElementRegistry"
553-
},
554-
"TextEncoder": {
555-
"exposeGlobally": true,
556-
"name": "TextEncoder",
557-
"override-type": "typeof TextEncoder"
558-
},
559-
"TextDecoder": {
560-
"exposeGlobally": true,
561-
"name": "TextDecoder",
562-
"override-type": "typeof TextDecoder"
537+
"type": "CustomElementRegistry"
563538
}
564539
}
565540
},

inputfiles/overridingTypes.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,9 @@
439439
"override-type": "Event | undefined",
440440
"deprecated": 1
441441
},
442+
"location": {
443+
"read-only": 0
444+
},
442445
"orientation": {
443446
"name": "orientation",
444447
"override-type": "string | number"
@@ -448,8 +451,11 @@
448451
"override-type": "any",
449452
"read-only": 0
450453
},
451-
"location": {
452-
"read-only": 0
454+
"self": {
455+
"override-type": "Window & typeof globalThis"
456+
},
457+
"window": {
458+
"override-type": "Window & typeof globalThis"
453459
}
454460
}
455461
},
@@ -2787,6 +2793,15 @@
27872793
}
27882794
}
27892795
}
2796+
},
2797+
"WorkerGlobalScope": {
2798+
"properties": {
2799+
"property": {
2800+
"self": {
2801+
"override-type": "WorkerGlobalScope & typeof globalThis"
2802+
}
2803+
}
2804+
}
27902805
}
27912806
}
27922807
},

0 commit comments

Comments
 (0)