Skip to content

Commit e9f5f98

Browse files
muj-begMuj.Beg
authored and
Muj.Beg
committed
Merge branch 'master' into TypeScript-Issue-18615
2 parents 3724c90 + 71140db commit e9f5f98

File tree

5 files changed

+33
-27
lines changed

5 files changed

+33
-27
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The common steps to send a pull request are:
2929
1. Add missing elements to `inputfiles/addedTypes.json`, overriding elements to `inputfiles/overridingTypes.json`, or elements to remove to `inputfiles/removedTypes.json`.
3030
2. Run the build script locally to obtain new `dom.generated.d.ts` and `webworker.generated.d.ts`.
3131
3. Update the files in the `baselines` folder using the newly generated files
32-
under `generated` folder (`cp ./generated/* ./baseline/`).
32+
under `generated` folder (`cp ./generated/* ./baselines/`).
3333

3434
### When should a DOM API be included here?
3535

TS.fsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ module Data =
535535
|> Array.map (fun i -> (i.Name, getEventHandler i))
536536
|> Map.ofArray
537537

538+
// Map of interface.Name -> List of base interfaces with event handlers
538539
let iNameToEhParents =
539540
let hasHandler (i : Browser.Interface) =
540541
iNameToEhList.ContainsKey i.Name && not iNameToEhList.[i.Name].IsEmpty
@@ -905,6 +906,16 @@ module Emit =
905906
| Some comment -> printLine "%s" comment
906907
| _ -> ()
907908

909+
// A covariant EventHandler is one that is defined in a parent interface as then redefined in current interface with a more specific argument types
910+
// These patterns are unsafe, and flagged as error under --strictFunctionTypes.
911+
// Here we know the property is already defined on the interface, we elide its declaration if the parent has the same handler defined
912+
let isCovariantEventHandler (p: Browser.Property) =
913+
p.Type = "EventHandler" &&
914+
iNameToEhParents.ContainsKey i.Name &&
915+
not iNameToEhParents.[i.Name].IsEmpty &&
916+
iNameToEhParents.[i.Name]
917+
|> List.exists (fun i -> iNameToEhList.ContainsKey i.Name && not iNameToEhList.[i.Name].IsEmpty && iNameToEhList.[i.Name] |> List.exists (fun e-> e.Name = p.Name))
918+
908919
let emitProperty (p: Browser.Property) =
909920
let printLine content =
910921
if conflictedMembers.Contains p.Name then Pt.PrintlToStack content else Pt.Printl content
@@ -941,6 +952,7 @@ module Emit =
941952
| Some ps ->
942953
ps.Properties
943954
|> Array.filter (ShouldKeep flavor)
955+
|> Array.filter (isCovariantEventHandler >> not)
944956
|> Array.iter emitProperty
945957
| None -> ()
946958

baselines/dom.generated.d.ts

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4233,11 +4233,7 @@ interface HTMLBodyElement extends HTMLElement {
42334233
onafterprint: (this: HTMLBodyElement, ev: Event) => any;
42344234
onbeforeprint: (this: HTMLBodyElement, ev: Event) => any;
42354235
onbeforeunload: (this: HTMLBodyElement, ev: BeforeUnloadEvent) => any;
4236-
onblur: (this: HTMLBodyElement, ev: FocusEvent) => any;
4237-
onerror: (this: HTMLBodyElement, ev: ErrorEvent) => any;
4238-
onfocus: (this: HTMLBodyElement, ev: FocusEvent) => any;
42394236
onhashchange: (this: HTMLBodyElement, ev: HashChangeEvent) => any;
4240-
onload: (this: HTMLBodyElement, ev: Event) => any;
42414237
onmessage: (this: HTMLBodyElement, ev: MessageEvent) => any;
42424238
onoffline: (this: HTMLBodyElement, ev: Event) => any;
42434239
ononline: (this: HTMLBodyElement, ev: Event) => any;
@@ -4246,7 +4242,6 @@ interface HTMLBodyElement extends HTMLElement {
42464242
onpageshow: (this: HTMLBodyElement, ev: PageTransitionEvent) => any;
42474243
onpopstate: (this: HTMLBodyElement, ev: PopStateEvent) => any;
42484244
onresize: (this: HTMLBodyElement, ev: UIEvent) => any;
4249-
onscroll: (this: HTMLBodyElement, ev: UIEvent) => any;
42504245
onstorage: (this: HTMLBodyElement, ev: StorageEvent) => any;
42514246
onunload: (this: HTMLBodyElement, ev: Event) => any;
42524247
text: any;
@@ -4838,6 +4833,7 @@ interface HTMLFormElement extends HTMLElement {
48384833
* Fires when a FORM is about to be submitted.
48394834
*/
48404835
submit(): void;
4836+
reportValidity(): boolean;
48414837
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLFormElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void;
48424838
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
48434839
[name: string]: any;
@@ -4901,10 +4897,6 @@ interface HTMLFrameElement extends HTMLElement, GetSVGDocument {
49014897
* Sets or retrieves whether the user can resize the frame.
49024898
*/
49034899
noResize: boolean;
4904-
/**
4905-
* Raised when the object has been completely received from the server.
4906-
*/
4907-
onload: (this: HTMLFrameElement, ev: Event) => any;
49084900
/**
49094901
* Sets or retrieves whether the frame can be scrolled.
49104902
*/
@@ -4970,17 +4962,7 @@ interface HTMLFrameSetElement extends HTMLElement {
49704962
onafterprint: (this: HTMLFrameSetElement, ev: Event) => any;
49714963
onbeforeprint: (this: HTMLFrameSetElement, ev: Event) => any;
49724964
onbeforeunload: (this: HTMLFrameSetElement, ev: BeforeUnloadEvent) => any;
4973-
/**
4974-
* Fires when the object loses the input focus.
4975-
*/
4976-
onblur: (this: HTMLFrameSetElement, ev: FocusEvent) => any;
4977-
onerror: (this: HTMLFrameSetElement, ev: ErrorEvent) => any;
4978-
/**
4979-
* Fires when the object receives focus.
4980-
*/
4981-
onfocus: (this: HTMLFrameSetElement, ev: FocusEvent) => any;
49824965
onhashchange: (this: HTMLFrameSetElement, ev: HashChangeEvent) => any;
4983-
onload: (this: HTMLFrameSetElement, ev: Event) => any;
49844966
onmessage: (this: HTMLFrameSetElement, ev: MessageEvent) => any;
49854967
onoffline: (this: HTMLFrameSetElement, ev: Event) => any;
49864968
ononline: (this: HTMLFrameSetElement, ev: Event) => any;
@@ -4989,7 +4971,6 @@ interface HTMLFrameSetElement extends HTMLElement {
49894971
onpageshow: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any;
49904972
onpopstate: (this: HTMLFrameSetElement, ev: PopStateEvent) => any;
49914973
onresize: (this: HTMLFrameSetElement, ev: UIEvent) => any;
4992-
onscroll: (this: HTMLFrameSetElement, ev: UIEvent) => any;
49934974
onstorage: (this: HTMLFrameSetElement, ev: StorageEvent) => any;
49944975
onunload: (this: HTMLFrameSetElement, ev: Event) => any;
49954976
/**
@@ -5125,10 +5106,6 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument {
51255106
* Sets or retrieves whether the user can resize the frame.
51265107
*/
51275108
noResize: boolean;
5128-
/**
5129-
* Raised when the object has been completely received from the server.
5130-
*/
5131-
onload: (this: HTMLIFrameElement, ev: Event) => any;
51325109
readonly sandbox: DOMSettableTokenList;
51335110
/**
51345111
* Sets or retrieves whether the frame can be scrolled.
@@ -8225,6 +8202,7 @@ interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorConte
82258202
readonly pointerEnabled: boolean;
82268203
readonly serviceWorker: ServiceWorkerContainer;
82278204
readonly webdriver: boolean;
8205+
readonly doNotTrack: string | null;
82288206
readonly hardwareConcurrency: number;
82298207
readonly languages: string[];
82308208
getGamepads(): Gamepad[];
@@ -14026,7 +14004,7 @@ interface EcKeyAlgorithm extends KeyAlgorithm {
1402614004
typedCurve: string;
1402714005
}
1402814006

14029-
interface EcKeyImportParams {
14007+
interface EcKeyImportParams extends Algorithm {
1403014008
namedCurve: string;
1403114009
}
1403214010

baselines/webworker.generated.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,7 @@ interface EcKeyAlgorithm extends KeyAlgorithm {
16421642
typedCurve: string;
16431643
}
16441644

1645-
interface EcKeyImportParams {
1645+
interface EcKeyImportParams extends Algorithm {
16461646
namedCurve: string;
16471647
}
16481648

inputfiles/addedTypes.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,13 @@
592592
"vibrate(pattern: number | number[]): boolean"
593593
]
594594
},
595+
{
596+
"kind": "property",
597+
"interface": "Navigator",
598+
"readonly": true,
599+
"name": "doNotTrack",
600+
"type": "string | null"
601+
},
595602
{
596603
"kind": "property",
597604
"interface": "Navigator",
@@ -853,6 +860,7 @@
853860
{
854861
"kind": "interface",
855862
"name": "EcKeyImportParams",
863+
"extends": "Algorithm",
856864
"properties": [
857865
{
858866
"name": "namedCurve",
@@ -1867,5 +1875,13 @@
18671875
]
18681876
}
18691877
]
1878+
},
1879+
{
1880+
"kind": "method",
1881+
"interface": "HTMLFormElement",
1882+
"name": "reportValidity",
1883+
"flavor": "DOM",
1884+
"signatures": [
1885+
"reportValidity(): boolean"
18701886
}
18711887
]

0 commit comments

Comments
 (0)