Skip to content

Commit b598925

Browse files
committed
fix(types): avoid using override-signatures, part 1
...and prefer overriding each param or return type. Still a long way to go.
1 parent be9121a commit b598925

File tree

6 files changed

+292
-265
lines changed

6 files changed

+292
-265
lines changed

baselines/dom.generated.d.ts

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3471,7 +3471,7 @@ interface CustomEvent<T = any> extends Event {
34713471
*/
34723472
readonly detail: T;
34733473
/** @deprecated */
3474-
initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: T): void;
3474+
initCustomEvent(type: string, bubbles?: boolean, cancelable?: boolean, detail?: T): void;
34753475
}
34763476

34773477
declare var CustomEvent: {
@@ -3821,7 +3821,7 @@ interface DOMTokenList {
38213821
*
38223822
* Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace.
38233823
*/
3824-
replace(oldToken: string, newToken: string): void;
3824+
replace(token: string, newToken: string): boolean;
38253825
/**
38263826
* Returns true if token is in the associated attribute's supported tokens. Returns false otherwise.
38273827
*
@@ -4221,8 +4221,6 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad
42214221
/** @deprecated */
42224222
captureEvents(): void;
42234223
/** @deprecated */
4224-
caretRangeFromPoint(x: number, y: number): Range;
4225-
/** @deprecated */
42264224
clear(): void;
42274225
/**
42284226
* Closes an output stream and forces the sent data to display.
@@ -4414,7 +4412,7 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad
44144412
*/
44154413
getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf<HTMLElement>;
44164414
getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf<SVGElement>;
4417-
getElementsByTagNameNS(namespaceURI: string, localName: string): HTMLCollectionOf<Element>;
4415+
getElementsByTagNameNS(namespace: string | null, localName: string): HTMLCollectionOf<Element>;
44184416
/**
44194417
* Returns an object representing the current selection of the document that is loaded into the object displaying a webpage.
44204418
*/
@@ -4436,7 +4434,8 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad
44364434
* @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported.
44374435
* @param replace Specifies whether the existing entry for the document is replaced in the history list.
44384436
*/
4439-
open(url?: string, name?: string, features?: string, replace?: boolean): Document;
4437+
open(unused1?: string, unused2?: string): Document;
4438+
open(url: string, name: string, features: string): WindowProxy | null;
44404439
/**
44414440
* Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document.
44424441
* @param commandId Specifies a command identifier.
@@ -4506,8 +4505,6 @@ interface DocumentAndElementEventHandlers {
45064505

45074506
/** A minimal document object that has no parent. It is used as a lightweight version of Document that stores a segment of a document structure comprised of nodes just like a standard document. The key difference is that because the document fragment isn't part of the active document tree structure, changes made to the fragment don't affect the document, cause reflow, or incur any performance impact that can occur when changes are made. */
45084507
interface DocumentFragment extends Node, NonElementParentNode, ParentNode {
4509-
readonly ownerDocument: Document;
4510-
getElementById(elementId: string): HTMLElement | null;
45114508
}
45124509

45134510
declare var DocumentFragment: {
@@ -4715,9 +4712,9 @@ interface Element extends Node, Animatable, ChildNode, InnerHTML, NonDocumentTyp
47154712
*/
47164713
hasAttributes(): boolean;
47174714
hasPointerCapture(pointerId: number): boolean;
4718-
insertAdjacentElement(position: InsertPosition, insertedElement: Element): Element | null;
4719-
insertAdjacentHTML(where: InsertPosition, html: string): void;
4720-
insertAdjacentText(where: InsertPosition, text: string): void;
4715+
insertAdjacentElement(where: InsertPosition, element: Element): Element | null;
4716+
insertAdjacentHTML(position: InsertPosition, text: string): void;
4717+
insertAdjacentText(where: InsertPosition, data: string): void;
47214718
/**
47224719
* Returns true if matching selectors against element's root yields element, and false otherwise.
47234720
*/
@@ -9354,9 +9351,9 @@ interface MediaQueryList extends EventTarget {
93549351
readonly media: string;
93559352
onchange: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null;
93569353
/** @deprecated */
9357-
addListener(listener: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null): void;
9354+
addListener(callback: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null): void;
93589355
/** @deprecated */
9359-
removeListener(listener: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null): void;
9356+
removeListener(callback: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null): void;
93609357
addEventListener<K extends keyof MediaQueryListEventMap>(type: K, listener: (this: MediaQueryList, ev: MediaQueryListEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
93619358
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
93629359
removeEventListener<K extends keyof MediaQueryListEventMap>(type: K, listener: (this: MediaQueryList, ev: MediaQueryListEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
@@ -9790,7 +9787,7 @@ interface Navigator extends NavigatorAutomationInformation, NavigatorConcurrentH
97909787
requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): Promise<MediaKeySystemAccess>;
97919788
sendBeacon(url: string, data?: BodyInit | null): boolean;
97929789
share(data?: ShareData): Promise<void>;
9793-
vibrate(pattern: number | number[]): boolean;
9790+
vibrate(pattern: VibratePattern): boolean;
97949791
}
97959792

97969793
declare var Navigator: {
@@ -15788,7 +15785,7 @@ interface WebGLRenderingContextBase {
1578815785
getExtension(extensionName: "OES_standard_derivatives"): OES_standard_derivatives | null;
1578915786
getExtension(extensionName: "OES_element_index_uint"): OES_element_index_uint | null;
1579015787
getExtension(extensionName: "ANGLE_instanced_arrays"): ANGLE_instanced_arrays | null;
15791-
getExtension(extensionName: string): any;
15788+
getExtension(name: string): any;
1579215789
getFramebufferAttachmentParameter(target: GLenum, attachment: GLenum, pname: GLenum): any;
1579315790
getParameter(pname: GLenum): any;
1579415791
getProgramInfoLog(program: WebGLProgram): string | null;
@@ -16406,7 +16403,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler
1640616403
matchMedia(query: string): MediaQueryList;
1640716404
moveBy(x: number, y: number): void;
1640816405
moveTo(x: number, y: number): void;
16409-
open(url?: string, target?: string, features?: string, replace?: boolean): Window | null;
16406+
open(url?: string, target?: string, features?: string): WindowProxy | null;
1641016407
/**
1641116408
* Posts a message to the given window. Messages can be structured objects, e.g. nested objects and arrays, can contain JavaScript values (strings, numbers, Date objects, etc), and can contain certain data objects such as File Blob, FileList, and ArrayBuffer objects.
1641216409
*
@@ -16419,6 +16416,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler
1641916416
* Throws a "DataCloneError" DOMException if transfer array contains duplicate objects or if message could not be cloned.
1642016417
*/
1642116418
postMessage(message: any, targetOrigin: string, transfer?: Transferable[]): void;
16419+
postMessage(message: any, options?: WindowPostMessageOptions): void;
1642216420
print(): void;
1642316421
prompt(message?: string, _default?: string): string | null;
1642416422
/** @deprecated */
@@ -17050,7 +17048,7 @@ interface PositionErrorCallback {
1705017048
}
1705117049

1705217050
interface QueuingStrategySize<T = any> {
17053-
(chunk: T): number;
17051+
(chunk?: T): number;
1705417052
}
1705517053

1705617054
interface RTCPeerConnectionErrorCallback {
@@ -17070,39 +17068,39 @@ interface TransformerFlushCallback<O> {
1707017068
}
1707117069

1707217070
interface TransformerStartCallback<O> {
17073-
(controller: TransformStreamDefaultController<O>): void | PromiseLike<void>;
17071+
(controller: TransformStreamDefaultController<O>): any;
1707417072
}
1707517073

1707617074
interface TransformerTransformCallback<I, O> {
1707717075
(chunk: I, controller: TransformStreamDefaultController<O>): void | PromiseLike<void>;
1707817076
}
1707917077

1708017078
interface UnderlyingSinkAbortCallback {
17081-
(reason: any): void | PromiseLike<void>;
17079+
(reason?: any): void | PromiseLike<void>;
1708217080
}
1708317081

1708417082
interface UnderlyingSinkCloseCallback {
1708517083
(): void | PromiseLike<void>;
1708617084
}
1708717085

1708817086
interface UnderlyingSinkStartCallback {
17089-
(controller: WritableStreamDefaultController): void | PromiseLike<void>;
17087+
(controller: WritableStreamDefaultController): any;
1709017088
}
1709117089

1709217090
interface UnderlyingSinkWriteCallback<W> {
1709317091
(chunk: W, controller: WritableStreamDefaultController): void | PromiseLike<void>;
1709417092
}
1709517093

1709617094
interface UnderlyingSourceCancelCallback {
17097-
(reason: any): void | PromiseLike<void>;
17095+
(reason?: any): void | PromiseLike<void>;
1709817096
}
1709917097

1710017098
interface UnderlyingSourcePullCallback<R> {
1710117099
(controller: ReadableStreamController<R>): void | PromiseLike<void>;
1710217100
}
1710317101

1710417102
interface UnderlyingSourceStartCallback<R> {
17105-
(controller: ReadableStreamController<R>): void | PromiseLike<void>;
17103+
(controller: ReadableStreamController<R>): any;
1710617104
}
1710717105

1710817106
interface VoidFunction {
@@ -17371,7 +17369,7 @@ declare function getSelection(): Selection | null;
1737117369
declare function matchMedia(query: string): MediaQueryList;
1737217370
declare function moveBy(x: number, y: number): void;
1737317371
declare function moveTo(x: number, y: number): void;
17374-
declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window | null;
17372+
declare function open(url?: string, target?: string, features?: string): WindowProxy | null;
1737517373
/**
1737617374
* Posts a message to the given window. Messages can be structured objects, e.g. nested objects and arrays, can contain JavaScript values (strings, numbers, Date objects, etc), and can contain certain data objects such as File Blob, FileList, and ArrayBuffer objects.
1737717375
*
@@ -17384,6 +17382,7 @@ declare function open(url?: string, target?: string, features?: string, replace?
1738417382
* Throws a "DataCloneError" DOMException if transfer array contains duplicate objects or if message could not be cloned.
1738517383
*/
1738617384
declare function postMessage(message: any, targetOrigin: string, transfer?: Transferable[]): void;
17385+
declare function postMessage(message: any, options?: WindowPostMessageOptions): void;
1738717386
declare function print(): void;
1738817387
declare function prompt(message?: string, _default?: string): string | null;
1738917388
/** @deprecated */

baselines/dom.iterable.generated.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ interface NamedNodeMap {
147147

148148
interface Navigator {
149149
requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: Iterable<MediaKeySystemConfiguration>): Promise<MediaKeySystemAccess>;
150+
vibrate(pattern: Iterable<number>): boolean;
150151
}
151152

152153
interface NodeList {
@@ -317,3 +318,18 @@ interface WebGLRenderingContextOverloads {
317318
uniformMatrix3fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Iterable<GLfloat>): void;
318319
uniformMatrix4fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Iterable<GLfloat>): void;
319320
}
321+
322+
interface Window {
323+
/**
324+
* Posts a message to the given window. Messages can be structured objects, e.g. nested objects and arrays, can contain JavaScript values (strings, numbers, Date objects, etc), and can contain certain data objects such as File Blob, FileList, and ArrayBuffer objects.
325+
*
326+
* Objects listed in the transfer member of options are transferred, not just cloned, meaning that they are no longer usable on the sending side.
327+
*
328+
* A target origin can be specified using the targetOrigin member of options. If not provided, it defaults to "/". This default restricts the message to same-origin targets only.
329+
*
330+
* If the origin of the target window doesn't match the given target origin, the message is discarded, to avoid information leakage. To send the message to the target regardless of origin, set the target origin to "*".
331+
*
332+
* Throws a "DataCloneError" DOMException if transfer array contains duplicate objects or if message could not be cloned.
333+
*/
334+
postMessage(message: any, targetOrigin: string, transfer?: Transferable[]): void;
335+
}

baselines/webworker.generated.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ interface CustomEvent<T = any> extends Event {
907907
*/
908908
readonly detail: T;
909909
/** @deprecated */
910-
initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: T): void;
910+
initCustomEvent(type: string, bubbles?: boolean, cancelable?: boolean, detail?: T): void;
911911
}
912912

913913
declare var CustomEvent: {
@@ -4534,7 +4534,7 @@ interface WebGLRenderingContextBase {
45344534
getExtension(extensionName: "OES_standard_derivatives"): OES_standard_derivatives | null;
45354535
getExtension(extensionName: "OES_element_index_uint"): OES_element_index_uint | null;
45364536
getExtension(extensionName: "ANGLE_instanced_arrays"): ANGLE_instanced_arrays | null;
4537-
getExtension(extensionName: string): any;
4537+
getExtension(name: string): any;
45384538
getFramebufferAttachmentParameter(target: GLenum, attachment: GLenum, pname: GLenum): any;
45394539
getParameter(pname: GLenum): any;
45404540
getProgramInfoLog(program: WebGLProgram): string | null;
@@ -5506,47 +5506,47 @@ interface PerformanceObserverCallback {
55065506
}
55075507

55085508
interface QueuingStrategySize<T = any> {
5509-
(chunk: T): number;
5509+
(chunk?: T): number;
55105510
}
55115511

55125512
interface TransformerFlushCallback<O> {
55135513
(controller: TransformStreamDefaultController<O>): void | PromiseLike<void>;
55145514
}
55155515

55165516
interface TransformerStartCallback<O> {
5517-
(controller: TransformStreamDefaultController<O>): void | PromiseLike<void>;
5517+
(controller: TransformStreamDefaultController<O>): any;
55185518
}
55195519

55205520
interface TransformerTransformCallback<I, O> {
55215521
(chunk: I, controller: TransformStreamDefaultController<O>): void | PromiseLike<void>;
55225522
}
55235523

55245524
interface UnderlyingSinkAbortCallback {
5525-
(reason: any): void | PromiseLike<void>;
5525+
(reason?: any): void | PromiseLike<void>;
55265526
}
55275527

55285528
interface UnderlyingSinkCloseCallback {
55295529
(): void | PromiseLike<void>;
55305530
}
55315531

55325532
interface UnderlyingSinkStartCallback {
5533-
(controller: WritableStreamDefaultController): void | PromiseLike<void>;
5533+
(controller: WritableStreamDefaultController): any;
55345534
}
55355535

55365536
interface UnderlyingSinkWriteCallback<W> {
55375537
(chunk: W, controller: WritableStreamDefaultController): void | PromiseLike<void>;
55385538
}
55395539

55405540
interface UnderlyingSourceCancelCallback {
5541-
(reason: any): void | PromiseLike<void>;
5541+
(reason?: any): void | PromiseLike<void>;
55425542
}
55435543

55445544
interface UnderlyingSourcePullCallback<R> {
55455545
(controller: ReadableStreamController<R>): void | PromiseLike<void>;
55465546
}
55475547

55485548
interface UnderlyingSourceStartCallback<R> {
5549-
(controller: ReadableStreamController<R>): void | PromiseLike<void>;
5549+
(controller: ReadableStreamController<R>): any;
55505550
}
55515551

55525552
interface VoidFunction {

0 commit comments

Comments
 (0)