Skip to content

Commit 7310818

Browse files
committed
Transform single array type correctly
1 parent 7a8e097 commit 7310818

File tree

2 files changed

+32
-29
lines changed

2 files changed

+32
-29
lines changed

src/DOM.res

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -642,11 +642,11 @@ and element = {
642642
/**
643643
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/innerHTML)
644644
*/
645-
mutable innerHTML: unknown,
645+
mutable innerHTML: string,
646646
/**
647647
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/outerHTML)
648648
*/
649-
mutable outerHTML: unknown,
649+
mutable outerHTML: string,
650650
}
651651

652652
/**
@@ -754,7 +754,7 @@ and shadowRoot = {
754754
/**
755755
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ShadowRoot/innerHTML)
756756
*/
757-
mutable innerHTML: unknown,
757+
mutable innerHTML: string,
758758
}
759759

760760
/**
@@ -891,11 +891,11 @@ and htmlElement = {
891891
/**
892892
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/innerHTML)
893893
*/
894-
mutable innerHTML: unknown,
894+
mutable innerHTML: string,
895895
/**
896896
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/outerHTML)
897897
*/
898-
mutable outerHTML: unknown,
898+
mutable outerHTML: string,
899899
// End base properties from Element
900900

901901
// Base properties from Node
@@ -1224,11 +1224,11 @@ and htmlHeadElement = {
12241224
/**
12251225
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/innerHTML)
12261226
*/
1227-
mutable innerHTML: unknown,
1227+
mutable innerHTML: string,
12281228
/**
12291229
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/outerHTML)
12301230
*/
1231-
mutable outerHTML: unknown,
1231+
mutable outerHTML: string,
12321232
// End base properties from Element
12331233

12341234
// Base properties from Node
@@ -1480,11 +1480,11 @@ and htmlFormElement = {
14801480
/**
14811481
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/innerHTML)
14821482
*/
1483-
mutable innerHTML: unknown,
1483+
mutable innerHTML: string,
14841484
/**
14851485
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/outerHTML)
14861486
*/
1487-
mutable outerHTML: unknown,
1487+
mutable outerHTML: string,
14881488
// End base properties from Element
14891489

14901490
// Base properties from Node
@@ -1787,11 +1787,11 @@ and htmlImageElement = {
17871787
/**
17881788
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/innerHTML)
17891789
*/
1790-
mutable innerHTML: unknown,
1790+
mutable innerHTML: string,
17911791
/**
17921792
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/outerHTML)
17931793
*/
1794-
mutable outerHTML: unknown,
1794+
mutable outerHTML: string,
17951795
// End base properties from Element
17961796

17971797
// Base properties from Node
@@ -2130,11 +2130,11 @@ and htmlEmbedElement = {
21302130
/**
21312131
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/innerHTML)
21322132
*/
2133-
mutable innerHTML: unknown,
2133+
mutable innerHTML: string,
21342134
/**
21352135
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/outerHTML)
21362136
*/
2137-
mutable outerHTML: unknown,
2137+
mutable outerHTML: string,
21382138
// End base properties from Element
21392139

21402140
// Base properties from Node
@@ -2402,11 +2402,11 @@ and htmlAnchorElement = {
24022402
/**
24032403
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/innerHTML)
24042404
*/
2405-
mutable innerHTML: unknown,
2405+
mutable innerHTML: string,
24062406
/**
24072407
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/outerHTML)
24082408
*/
2409-
mutable outerHTML: unknown,
2409+
mutable outerHTML: string,
24102410
// End base properties from Element
24112411

24122412
// Base properties from Node
@@ -2700,11 +2700,11 @@ and htmlAreaElement = {
27002700
/**
27012701
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/innerHTML)
27022702
*/
2703-
mutable innerHTML: unknown,
2703+
mutable innerHTML: string,
27042704
/**
27052705
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/outerHTML)
27062706
*/
2707-
mutable outerHTML: unknown,
2707+
mutable outerHTML: string,
27082708
// End base properties from Element
27092709

27102710
// Base properties from Node
@@ -2978,11 +2978,11 @@ and htmlScriptElement = {
29782978
/**
29792979
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/innerHTML)
29802980
*/
2981-
mutable innerHTML: unknown,
2981+
mutable innerHTML: string,
29822982
/**
29832983
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/outerHTML)
29842984
*/
2985-
mutable outerHTML: unknown,
2985+
mutable outerHTML: string,
29862986
// End base properties from Element
29872987

29882988
// Base properties from Node
@@ -7291,7 +7291,7 @@ type htmliFrameElement = {
72917291
Sets or retrives the content of the page that is to contain.
72927292
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLIFrameElement/srcdoc)
72937293
*/
7294-
mutable srcdoc: unknown,
7294+
mutable srcdoc: string,
72957295
/**
72967296
Sets or retrieves the frame name.
72977297
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLIFrameElement/name)

tools/TypeScript-DOM-lib-generator/src/build/emitter.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,12 @@ export async function emitRescriptBindings(
569569
}
570570

571571
function transformTyped(typed: Browser.Typed): string {
572+
if (Array.isArray(typed.type) && typed.type.length === 1) {
573+
return transformTyped(typed.type[0]);
574+
}
575+
572576
if (typeof typed.type !== "string") {
577+
console.log("Unknown type", typed.type);
573578
return "unknown";
574579
}
575580

@@ -634,17 +639,15 @@ export async function emitRescriptBindings(
634639
i: Browser.Interface | Browser.Dictionary,
635640
property: Browser.Member,
636641
): string {
637-
if (typeof property.type === "string") {
638-
if (i.name === "Event" && property.name === "type") {
639-
return "eventType";
640-
}
641-
642-
return transformTyped(property);
643-
} else {
644-
console.log("non string property type", property.type);
642+
if (
643+
typeof property.type === "string" &&
644+
i.name === "Event" &&
645+
property.name === "type"
646+
) {
647+
return "eventType";
645648
}
646649

647-
return "unknown";
650+
return transformTyped(property);
648651
}
649652

650653
function emitProperty(i: Browser.Interface, property: Browser.Property) {

0 commit comments

Comments
 (0)