Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12234,7 +12234,7 @@ interface Document extends Node, DocumentOrShadowRoot, FontFaceSource, GlobalEve
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/defaultView)
*/
readonly defaultView: (WindowProxy & typeof globalThis) | null;
readonly defaultView: Globalized<WindowProxy> | null;
/**
* **`document.designMode`** controls whether the entire document is editable. Valid values are "on" and "off". According to the specification, this property is meant to default to "off". Firefox follows this standard. The earlier versions of Chrome and IE default to "inherit". Starting in Chrome 43, the default is "off" and "inherit" is no longer supported. In IE6-10, the value is capitalized.
*
Expand Down Expand Up @@ -39699,7 +39699,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/self)
*/
readonly self: Window & typeof globalThis;
readonly self: Globalized;
/**
* The **`speechSynthesis`** read-only property of the Window object returns a SpeechSynthesis object, which is the entry point into using Web Speech API speech synthesis functionality.
*
Expand Down Expand Up @@ -39742,7 +39742,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/window)
*/
readonly window: Window & typeof globalThis;
readonly window: Globalized;
/**
* **`window.alert()`** instructs the browser to display a dialog with an optional message, and to wait until the user dismisses the dialog.
*
Expand Down Expand Up @@ -41881,7 +41881,7 @@ declare var scrollbars: BarProp;
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/self)
*/
declare var self: Window & typeof globalThis;
declare var self: Globalized;
/**
* The **`speechSynthesis`** read-only property of the Window object returns a SpeechSynthesis object, which is the entry point into using Web Speech API speech synthesis functionality.
*
Expand Down Expand Up @@ -41924,7 +41924,7 @@ declare var visualViewport: VisualViewport | null;
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/window)
*/
declare var window: Window & typeof globalThis;
declare var window: Globalized;
/**
* **`window.alert()`** instructs the browser to display a dialog with an optional message, and to wait until the user dismisses the dialog.
*
Expand Down Expand Up @@ -42450,6 +42450,7 @@ type GLsizei = number;
type GLsizeiptr = number;
type GLuint = number;
type GLuint64 = number;
type Globalized<T = Window> = T & typeof globalThis;
type HTMLOrSVGImageElement = HTMLImageElement | SVGImageElement;
type HTMLOrSVGScriptElement = HTMLScriptElement | SVGScriptElement;
type HashAlgorithmIdentifier = AlgorithmIdentifier;
Expand Down
11 changes: 6 additions & 5 deletions baselines/ts5.5/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12223,7 +12223,7 @@ interface Document extends Node, DocumentOrShadowRoot, FontFaceSource, GlobalEve
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/defaultView)
*/
readonly defaultView: (WindowProxy & typeof globalThis) | null;
readonly defaultView: Globalized<WindowProxy> | null;
/**
* **`document.designMode`** controls whether the entire document is editable. Valid values are "on" and "off". According to the specification, this property is meant to default to "off". Firefox follows this standard. The earlier versions of Chrome and IE default to "inherit". Starting in Chrome 43, the default is "off" and "inherit" is no longer supported. In IE6-10, the value is capitalized.
*
Expand Down Expand Up @@ -39673,7 +39673,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/self)
*/
readonly self: Window & typeof globalThis;
readonly self: Globalized;
/**
* The **`speechSynthesis`** read-only property of the Window object returns a SpeechSynthesis object, which is the entry point into using Web Speech API speech synthesis functionality.
*
Expand Down Expand Up @@ -39716,7 +39716,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/window)
*/
readonly window: Window & typeof globalThis;
readonly window: Globalized;
/**
* **`window.alert()`** instructs the browser to display a dialog with an optional message, and to wait until the user dismisses the dialog.
*
Expand Down Expand Up @@ -41855,7 +41855,7 @@ declare var scrollbars: BarProp;
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/self)
*/
declare var self: Window & typeof globalThis;
declare var self: Globalized;
/**
* The **`speechSynthesis`** read-only property of the Window object returns a SpeechSynthesis object, which is the entry point into using Web Speech API speech synthesis functionality.
*
Expand Down Expand Up @@ -41898,7 +41898,7 @@ declare var visualViewport: VisualViewport | null;
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/window)
*/
declare var window: Window & typeof globalThis;
declare var window: Globalized;
/**
* **`window.alert()`** instructs the browser to display a dialog with an optional message, and to wait until the user dismisses the dialog.
*
Expand Down Expand Up @@ -42424,6 +42424,7 @@ type GLsizei = number;
type GLsizeiptr = number;
type GLuint = number;
type GLuint64 = number;
type Globalized<T = Window> = T & typeof globalThis;
type HTMLOrSVGImageElement = HTMLImageElement | SVGImageElement;
type HTMLOrSVGScriptElement = HTMLScriptElement | SVGScriptElement;
type HashAlgorithmIdentifier = AlgorithmIdentifier;
Expand Down
11 changes: 6 additions & 5 deletions baselines/ts5.6/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12231,7 +12231,7 @@ interface Document extends Node, DocumentOrShadowRoot, FontFaceSource, GlobalEve
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/defaultView)
*/
readonly defaultView: (WindowProxy & typeof globalThis) | null;
readonly defaultView: Globalized<WindowProxy> | null;
/**
* **`document.designMode`** controls whether the entire document is editable. Valid values are "on" and "off". According to the specification, this property is meant to default to "off". Firefox follows this standard. The earlier versions of Chrome and IE default to "inherit". Starting in Chrome 43, the default is "off" and "inherit" is no longer supported. In IE6-10, the value is capitalized.
*
Expand Down Expand Up @@ -39696,7 +39696,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/self)
*/
readonly self: Window & typeof globalThis;
readonly self: Globalized;
/**
* The **`speechSynthesis`** read-only property of the Window object returns a SpeechSynthesis object, which is the entry point into using Web Speech API speech synthesis functionality.
*
Expand Down Expand Up @@ -39739,7 +39739,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/window)
*/
readonly window: Window & typeof globalThis;
readonly window: Globalized;
/**
* **`window.alert()`** instructs the browser to display a dialog with an optional message, and to wait until the user dismisses the dialog.
*
Expand Down Expand Up @@ -41878,7 +41878,7 @@ declare var scrollbars: BarProp;
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/self)
*/
declare var self: Window & typeof globalThis;
declare var self: Globalized;
/**
* The **`speechSynthesis`** read-only property of the Window object returns a SpeechSynthesis object, which is the entry point into using Web Speech API speech synthesis functionality.
*
Expand Down Expand Up @@ -41921,7 +41921,7 @@ declare var visualViewport: VisualViewport | null;
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/window)
*/
declare var window: Window & typeof globalThis;
declare var window: Globalized;
/**
* **`window.alert()`** instructs the browser to display a dialog with an optional message, and to wait until the user dismisses the dialog.
*
Expand Down Expand Up @@ -42447,6 +42447,7 @@ type GLsizei = number;
type GLsizeiptr = number;
type GLuint = number;
type GLuint64 = number;
type Globalized<T = Window> = T & typeof globalThis;
type HTMLOrSVGImageElement = HTMLImageElement | SVGImageElement;
type HTMLOrSVGScriptElement = HTMLScriptElement | SVGScriptElement;
type HashAlgorithmIdentifier = AlgorithmIdentifier;
Expand Down
11 changes: 6 additions & 5 deletions baselines/ts5.9/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12231,7 +12231,7 @@ interface Document extends Node, DocumentOrShadowRoot, FontFaceSource, GlobalEve
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/defaultView)
*/
readonly defaultView: (WindowProxy & typeof globalThis) | null;
readonly defaultView: Globalized<WindowProxy> | null;
/**
* **`document.designMode`** controls whether the entire document is editable. Valid values are "on" and "off". According to the specification, this property is meant to default to "off". Firefox follows this standard. The earlier versions of Chrome and IE default to "inherit". Starting in Chrome 43, the default is "off" and "inherit" is no longer supported. In IE6-10, the value is capitalized.
*
Expand Down Expand Up @@ -39696,7 +39696,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/self)
*/
readonly self: Window & typeof globalThis;
readonly self: Globalized;
/**
* The **`speechSynthesis`** read-only property of the Window object returns a SpeechSynthesis object, which is the entry point into using Web Speech API speech synthesis functionality.
*
Expand Down Expand Up @@ -39739,7 +39739,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/window)
*/
readonly window: Window & typeof globalThis;
readonly window: Globalized;
/**
* **`window.alert()`** instructs the browser to display a dialog with an optional message, and to wait until the user dismisses the dialog.
*
Expand Down Expand Up @@ -41878,7 +41878,7 @@ declare var scrollbars: BarProp;
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/self)
*/
declare var self: Window & typeof globalThis;
declare var self: Globalized;
/**
* The **`speechSynthesis`** read-only property of the Window object returns a SpeechSynthesis object, which is the entry point into using Web Speech API speech synthesis functionality.
*
Expand Down Expand Up @@ -41921,7 +41921,7 @@ declare var visualViewport: VisualViewport | null;
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/window)
*/
declare var window: Window & typeof globalThis;
declare var window: Globalized;
/**
* **`window.alert()`** instructs the browser to display a dialog with an optional message, and to wait until the user dismisses the dialog.
*
Expand Down Expand Up @@ -42447,6 +42447,7 @@ type GLsizei = number;
type GLsizeiptr = number;
type GLuint = number;
type GLuint64 = number;
type Globalized<T = Window> = T & typeof globalThis;
type HTMLOrSVGImageElement = HTMLImageElement | SVGImageElement;
type HTMLOrSVGScriptElement = HTMLScriptElement | SVGScriptElement;
type HashAlgorithmIdentifier = AlgorithmIdentifier;
Expand Down
17 changes: 0 additions & 17 deletions inputfiles/overridingTypes.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,6 @@
"onorientationchange": {
"deprecated": true
},
"self": {
"overrideType": "Window & typeof globalThis"
},
"window": {
"overrideType": "Window & typeof globalThis"
},
"pageXOffset": {
// While this is indeed an alias of scrollX, it's not a vendor prefixed legacy as aliases usually are.
"deprecated": false
Expand Down Expand Up @@ -539,10 +533,6 @@
},
"properties": {
"property": {
"defaultView": {
"name": "defaultView",
"overrideType": "WindowProxy & typeof globalThis"
},
"documentElement": {
"name": "documentElement",
"overrideType": "HTMLElement",
Expand Down Expand Up @@ -2798,13 +2788,6 @@
}
},
"WorkerGlobalScope": {
"properties": {
"property": {
"self": {
"overrideType": "WorkerGlobalScope & typeof globalThis"
}
}
},
"events": {
"event": [
{
Expand Down
8 changes: 8 additions & 0 deletions inputfiles/patches/dom.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ interface EventListenerObject noInterfaceObject=#true {
}
}

interface Document {
property defaultView {
type Globalized {
type WindowProxy
}
}
}

enum InsertPosition {
beforebegin
beforeend
Expand Down
14 changes: 14 additions & 0 deletions inputfiles/patches/html.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,22 @@ interface HTMLInputElement {
}
}

interface Window {
property self type=Globalized
property window type=Globalized
}

interface WorkerGlobalScope {
// We must declare it in overrideType, because Window doesn't exist in WebWorkers
property self overrideType="WorkerGlobalScope & typeof globalThis"
}

typedef SelectionDirection overrideType=#""forward" | "backward" | "none""#

typedef Globalized overrideType="T & typeof globalThis" {
typeParameters T default="Window"
}

dictionary StructuredSerializeOptions {
member transfer {
type {
Expand Down
18 changes: 17 additions & 1 deletion src/build/patches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,25 @@ function handleMember(c: Node): DeepPartial<Member> {
* @param node The typedef node to handle.
*/
function handleTypedef(node: Node): DeepPartial<TypeDef> {
const typeNodes = node.children.filter((c) => c.name === "type");
// Support type params: collect "type" and "typeParameters" child nodes
const typeNodes: Node[] = [];
let typeParameters = {};

for (const c of node.children) {
switch (c.name) {
case "type":
typeNodes.push(c);
break;
case "typeParameters":
typeParameters = handleTypeParameters(c);
break;
default:
throw new Error(`Unexpected child "${c.name}"`);
}
}
return {
name: string(node.values[0]),
...typeParameters,
...handleTyped(typeNodes),
...optionalMember(
"legacyNamespace",
Expand Down