Skip to content
Merged
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
5 changes: 3 additions & 2 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17341,7 +17341,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/selectionDirection)
*/
selectionDirection: "forward" | "backward" | "none" | null;
selectionDirection: SelectionDirection | null;
/**
* The **`selectionEnd`** property of the HTMLInputElement interface is a number that represents the end index of the selected text. That is, it represents the index of the character immediately following the selection. Likewise, when there is no selection, this returns the offset of the character immediately following the current text input cursor position.
*
Expand Down Expand Up @@ -17470,7 +17470,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/setSelectionRange)
*/
setSelectionRange(start: number | null, end: number | null, direction?: "forward" | "backward" | "none"): void;
setSelectionRange(start: number | null, end: number | null, direction?: SelectionDirection): void;
/**
* The **`HTMLInputElement.showPicker()`** method displays the browser picker for an input element.
*
Expand Down Expand Up @@ -42478,6 +42478,7 @@ type ReadableStreamReader<T> = ReadableStreamDefaultReader<T> | ReadableStreamBY
type RenderingContext = CanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext;
type ReportList = Report[];
type RequestInfo = Request | string;
type SelectionDirection = "forward" | "backward" | "none";
type TexImageSource = ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas | VideoFrame;
type TimerHandler = string | Function;
type Transferable = OffscreenCanvas | ImageBitmap | MessagePort | MediaSourceHandle | ReadableStream | WritableStream | TransformStream | AudioData | VideoFrame | RTCDataChannel | ArrayBuffer;
Expand Down
5 changes: 3 additions & 2 deletions baselines/ts5.5/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17323,7 +17323,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/selectionDirection)
*/
selectionDirection: "forward" | "backward" | "none" | null;
selectionDirection: SelectionDirection | null;
/**
* The **`selectionEnd`** property of the HTMLInputElement interface is a number that represents the end index of the selected text. That is, it represents the index of the character immediately following the selection. Likewise, when there is no selection, this returns the offset of the character immediately following the current text input cursor position.
*
Expand Down Expand Up @@ -17452,7 +17452,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/setSelectionRange)
*/
setSelectionRange(start: number | null, end: number | null, direction?: "forward" | "backward" | "none"): void;
setSelectionRange(start: number | null, end: number | null, direction?: SelectionDirection): void;
/**
* The **`HTMLInputElement.showPicker()`** method displays the browser picker for an input element.
*
Expand Down Expand Up @@ -42452,6 +42452,7 @@ type ReadableStreamReader<T> = ReadableStreamDefaultReader<T> | ReadableStreamBY
type RenderingContext = CanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext;
type ReportList = Report[];
type RequestInfo = Request | string;
type SelectionDirection = "forward" | "backward" | "none";
type TexImageSource = ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas | VideoFrame;
type TimerHandler = string | Function;
type Transferable = OffscreenCanvas | ImageBitmap | MessagePort | MediaSourceHandle | ReadableStream | WritableStream | TransformStream | AudioData | VideoFrame | RTCDataChannel | ArrayBuffer;
Expand Down
5 changes: 3 additions & 2 deletions baselines/ts5.6/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17338,7 +17338,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/selectionDirection)
*/
selectionDirection: "forward" | "backward" | "none" | null;
selectionDirection: SelectionDirection | null;
/**
* The **`selectionEnd`** property of the HTMLInputElement interface is a number that represents the end index of the selected text. That is, it represents the index of the character immediately following the selection. Likewise, when there is no selection, this returns the offset of the character immediately following the current text input cursor position.
*
Expand Down Expand Up @@ -17467,7 +17467,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/setSelectionRange)
*/
setSelectionRange(start: number | null, end: number | null, direction?: "forward" | "backward" | "none"): void;
setSelectionRange(start: number | null, end: number | null, direction?: SelectionDirection): void;
/**
* The **`HTMLInputElement.showPicker()`** method displays the browser picker for an input element.
*
Expand Down Expand Up @@ -42475,6 +42475,7 @@ type ReadableStreamReader<T> = ReadableStreamDefaultReader<T> | ReadableStreamBY
type RenderingContext = CanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext;
type ReportList = Report[];
type RequestInfo = Request | string;
type SelectionDirection = "forward" | "backward" | "none";
type TexImageSource = ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas | VideoFrame;
type TimerHandler = string | Function;
type Transferable = OffscreenCanvas | ImageBitmap | MessagePort | MediaSourceHandle | ReadableStream | WritableStream | TransformStream | AudioData | VideoFrame | RTCDataChannel | ArrayBuffer;
Expand Down
5 changes: 3 additions & 2 deletions baselines/ts5.9/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17338,7 +17338,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/selectionDirection)
*/
selectionDirection: "forward" | "backward" | "none" | null;
selectionDirection: SelectionDirection | null;
/**
* The **`selectionEnd`** property of the HTMLInputElement interface is a number that represents the end index of the selected text. That is, it represents the index of the character immediately following the selection. Likewise, when there is no selection, this returns the offset of the character immediately following the current text input cursor position.
*
Expand Down Expand Up @@ -17467,7 +17467,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes {
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/setSelectionRange)
*/
setSelectionRange(start: number | null, end: number | null, direction?: "forward" | "backward" | "none"): void;
setSelectionRange(start: number | null, end: number | null, direction?: SelectionDirection): void;
/**
* The **`HTMLInputElement.showPicker()`** method displays the browser picker for an input element.
*
Expand Down Expand Up @@ -42475,6 +42475,7 @@ type ReadableStreamReader<T> = ReadableStreamDefaultReader<T> | ReadableStreamBY
type RenderingContext = CanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext;
type ReportList = Report[];
type RequestInfo = Request | string;
type SelectionDirection = "forward" | "backward" | "none";
type TexImageSource = ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas | VideoFrame;
type TimerHandler = string | Function;
type Transferable = OffscreenCanvas | ImageBitmap | MessagePort | MediaSourceHandle | ReadableStream | WritableStream | TransformStream | AudioData | VideoFrame | RTCDataChannel | ArrayBuffer;
Expand Down
9 changes: 0 additions & 9 deletions inputfiles/addedTypes.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,6 @@
}
}
},
"HTMLInputElement": {
"properties": {
"property": {
"labels": {
"overrideType": "NodeListOf<HTMLLabelElement>"
}
}
}
},
"RuntimeError": {
"name": "RuntimeError",
"extends": "Error",
Expand Down
1 change: 0 additions & 1 deletion inputfiles/knownTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"AutoFillContactField",
"AutoFillField",
"AutoFillCredentialField",
"AutoFill",
"BigInteger",
"ClientQueryOptions",
"ClientTypes",
Expand Down
42 changes: 0 additions & 42 deletions inputfiles/overridingTypes.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -1445,48 +1445,6 @@
}
}
},
"HTMLInputElement": {
"properties": {
"property": {
"autocomplete": {
"name": "autocomplete",
"overrideType": "AutoFill"
},
"selectionDirection": {
"name": "selectionDirection",
"overrideType": "\"forward\" | \"backward\" | \"none\""
},
"valueAsDate": {
"name": "valueAsDate",
"overrideType": "Date"
}
}
},
"methods": {
"method": {
"setSelectionRange": {
"signature": {
"0": {
"param": [
{
"name": "start",
"nullable": true
},
{
"name": "end",
"nullable": true
},
{
"name": "direction",
"overrideType": "\"forward\" | \"backward\" | \"none\""
}
]
}
}
}
}
}
},
"MouseEvent": {
"methods": {
"method": {
Expand Down
24 changes: 24 additions & 0 deletions inputfiles/patches/html.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,30 @@ interface HTMLImageElement {
property loading overrideType=#""eager" | "lazy""#
}

interface HTMLInputElement {
property labels {
type NodeListOf {
type HTMLLabelElement
}
}
property autocomplete type=AutoFill
property valueAsDate type=Date
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this should be allowed, Date is not an IDL type. But maybe not worth disallowing it... Let's see.

property selectionDirection type=SelectionDirection
method setSelectionRange signatureIndex=0 {
// nullable types because we want to allow passing selectionStart/End properties, which are nullable.
// See also https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/878.
param start {
type nullable=#true
}
param end {
type nullable=#true
}
param direction type=SelectionDirection
}
}

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

dictionary StructuredSerializeOptions {
member transfer {
type {
Expand Down
10 changes: 8 additions & 2 deletions src/build/patches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ function handleProperty(child: Node): DeepPartial<Property> {
function handleParam(node: Node) {
const name = string(node.values[0]);
let additionalTypes: string[] | undefined;
const typeNodes: Node[] = [];

for (const child of node.children) {
switch (child.name) {
Expand All @@ -317,14 +318,18 @@ function handleParam(node: Node) {
additionalTypes = child.values.map(string);
break;
}
case "type": {
typeNodes.push(child);
break;
}
default:
throw new Error(`Unexpected child "${child.name}" in param "${name}"`);
}
}

return {
name,
...optionalMember("type", "string", node.properties?.type),
...handleTyped(typeNodes, node.properties?.type),
...optionalMember("overrideType", "string", node.properties?.overrideType),
additionalTypes,
};
Expand All @@ -343,7 +348,7 @@ function handleMethodAndConstructor(

// Collect all type nodes into an array
const typeNodes: Node[] = [];
const params: Partial<Param>[] = [];
const params: DeepPartial<Param>[] = [];

for (const c of child.children) {
switch (c.name) {
Expand Down Expand Up @@ -452,6 +457,7 @@ function handleTypedef(node: Node): DeepPartial<TypeDef> {
"string",
node.properties?.legacyNamespace,
),
...optionalMember("overrideType", "string", node.properties?.overrideType),
};
}

Expand Down