From 3c892a3fa55cc394ef46b8d55bcdd93cde3d674f Mon Sep 17 00:00:00 2001 From: Bashamega Date: Sun, 14 Dec 2025 07:04:44 +0200 Subject: [PATCH 01/10] Add support for type parameters and nullable property in handleMixinAndInterfaces --- inputfiles/overridingTypes.jsonc | 20 -------------------- inputfiles/patches/indexeddb.kdl | 5 +++++ src/build/patches.ts | 7 +++++++ 3 files changed, 12 insertions(+), 20 deletions(-) create mode 100644 inputfiles/patches/indexeddb.kdl diff --git a/inputfiles/overridingTypes.jsonc b/inputfiles/overridingTypes.jsonc index 8c7d9849f..27ae7ec0d 100644 --- a/inputfiles/overridingTypes.jsonc +++ b/inputfiles/overridingTypes.jsonc @@ -1310,26 +1310,6 @@ } } }, - "IDBRequest": { - "properties": { - "property": { - "source": { - "name": "source", - "nullable": false - }, - "result": { - "name": "result", - "overrideType": "T" - } - } - }, - "typeParameters": [ - { - "name": "T", - "default": "any" - } - ] - }, "ImageBitmapRenderingContext": { "properties": { "property": { diff --git a/inputfiles/patches/indexeddb.kdl b/inputfiles/patches/indexeddb.kdl new file mode 100644 index 000000000..11318bd0d --- /dev/null +++ b/inputfiles/patches/indexeddb.kdl @@ -0,0 +1,5 @@ +interface IDBRequest { + property source nullable=#false + property result overrideType=T + typeParameters T default=any +} \ No newline at end of file diff --git a/src/build/patches.ts b/src/build/patches.ts index fe79fcb3e..01774fe3c 100644 --- a/src/build/patches.ts +++ b/src/build/patches.ts @@ -169,6 +169,7 @@ function handleMixinAndInterfaces( const event: Event[] = []; const property: Record> = {}; let method: Record> = {}; + let typeParameters = {} for (const child of node.children) { switch (child.name) { @@ -188,12 +189,17 @@ function handleMixinAndInterfaces( }); break; } + case "typeParameters": { + typeParameters = handleTypeParameters(child); + break; + } default: throw new Error(`Unknown node name: ${child.name}`); } } const interfaceObject = type === "interface" && { + ...typeParameters, ...optionalMember("exposed", "string", node.properties?.exposed), ...optionalMember("deprecated", "string", node.properties?.deprecated), ...optionalMember( @@ -259,6 +265,7 @@ function handleProperty(child: Node): Partial { : optionalMember("type", "string", child.properties?.type)), ...optionalMember("readonly", "boolean", child.properties?.readonly), ...optionalMember("deprecated", "string", child.properties?.deprecated), + ...optionalMember("nullable", "boolean", child.properties?.nullable), }; } From b1f05bbb2d306c6873417a89312a0a3f12ad80c2 Mon Sep 17 00:00:00 2001 From: Bashamega Date: Sun, 14 Dec 2025 07:06:36 +0200 Subject: [PATCH 02/10] format --- inputfiles/patches/indexeddb.kdl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inputfiles/patches/indexeddb.kdl b/inputfiles/patches/indexeddb.kdl index 11318bd0d..486976a54 100644 --- a/inputfiles/patches/indexeddb.kdl +++ b/inputfiles/patches/indexeddb.kdl @@ -2,4 +2,4 @@ interface IDBRequest { property source nullable=#false property result overrideType=T typeParameters T default=any -} \ No newline at end of file +} From bff3d2bfb2171872c608716d09f0b704ad47ae80 Mon Sep 17 00:00:00 2001 From: Bashamega Date: Sun, 14 Dec 2025 07:07:14 +0200 Subject: [PATCH 03/10] - --- src/build/patches.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build/patches.ts b/src/build/patches.ts index 01774fe3c..f6ace94ba 100644 --- a/src/build/patches.ts +++ b/src/build/patches.ts @@ -169,7 +169,7 @@ function handleMixinAndInterfaces( const event: Event[] = []; const property: Record> = {}; let method: Record> = {}; - let typeParameters = {} + let typeParameters = {}; for (const child of node.children) { switch (child.name) { From 053aadbace17209f3d19565cadb88ac56d1682db Mon Sep 17 00:00:00 2001 From: Adam Naji <110662505+Bashamega@users.noreply.github.com> Date: Sun, 14 Dec 2025 17:22:24 +0200 Subject: [PATCH 04/10] Change property result declaration in IDBRequest --- inputfiles/patches/indexeddb.kdl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inputfiles/patches/indexeddb.kdl b/inputfiles/patches/indexeddb.kdl index 486976a54..44646ebb4 100644 --- a/inputfiles/patches/indexeddb.kdl +++ b/inputfiles/patches/indexeddb.kdl @@ -1,5 +1,5 @@ interface IDBRequest { property source nullable=#false - property result overrideType=T + property result type=T typeParameters T default=any } From 8f781841526a99e12129d51c87101aa8960fcc26 Mon Sep 17 00:00:00 2001 From: Adam Naji <110662505+Bashamega@users.noreply.github.com> Date: Sun, 14 Dec 2025 17:23:58 +0200 Subject: [PATCH 05/10] Override result property in IDBRequest interface --- inputfiles/patches/indexeddb.kdl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inputfiles/patches/indexeddb.kdl b/inputfiles/patches/indexeddb.kdl index 44646ebb4..486976a54 100644 --- a/inputfiles/patches/indexeddb.kdl +++ b/inputfiles/patches/indexeddb.kdl @@ -1,5 +1,5 @@ interface IDBRequest { property source nullable=#false - property result type=T + property result overrideType=T typeParameters T default=any } From d3c69df63362367f858e6fd2b5256d9fd3515d5a Mon Sep 17 00:00:00 2001 From: Adam Naji <110662505+Bashamega@users.noreply.github.com> Date: Sun, 14 Dec 2025 19:47:21 +0200 Subject: [PATCH 06/10] Test to see if it would work without it --- inputfiles/patches/indexeddb.kdl | 1 - 1 file changed, 1 deletion(-) diff --git a/inputfiles/patches/indexeddb.kdl b/inputfiles/patches/indexeddb.kdl index 486976a54..dd5e20881 100644 --- a/inputfiles/patches/indexeddb.kdl +++ b/inputfiles/patches/indexeddb.kdl @@ -1,5 +1,4 @@ interface IDBRequest { - property source nullable=#false property result overrideType=T typeParameters T default=any } From 6e2b393bc1dba29d514b863579e92852cfbe7c6b Mon Sep 17 00:00:00 2001 From: Adam Naji <110662505+Bashamega@users.noreply.github.com> Date: Sun, 14 Dec 2025 19:54:44 +0200 Subject: [PATCH 07/10] Update indexeddb.kdl --- inputfiles/patches/indexeddb.kdl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/inputfiles/patches/indexeddb.kdl b/inputfiles/patches/indexeddb.kdl index dd5e20881..01c675cd3 100644 --- a/inputfiles/patches/indexeddb.kdl +++ b/inputfiles/patches/indexeddb.kdl @@ -1,4 +1,7 @@ interface IDBRequest { + property source { + type "" nullable=#false + } property result overrideType=T typeParameters T default=any } From e18f6b2312a52d544b0aabcfccd17d329937864e Mon Sep 17 00:00:00 2001 From: Adam Naji <110662505+Bashamega@users.noreply.github.com> Date: Sun, 14 Dec 2025 19:57:47 +0200 Subject: [PATCH 08/10] Update patches.ts --- src/build/patches.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/build/patches.ts b/src/build/patches.ts index f6ace94ba..bf0550a7f 100644 --- a/src/build/patches.ts +++ b/src/build/patches.ts @@ -265,7 +265,6 @@ function handleProperty(child: Node): Partial { : optionalMember("type", "string", child.properties?.type)), ...optionalMember("readonly", "boolean", child.properties?.readonly), ...optionalMember("deprecated", "string", child.properties?.deprecated), - ...optionalMember("nullable", "boolean", child.properties?.nullable), }; } From 839d07b5e17871d19d63ae6be2ed9158589bbef7 Mon Sep 17 00:00:00 2001 From: Bashamega Date: Mon, 15 Dec 2025 15:43:24 +0200 Subject: [PATCH 09/10] Move it to the top --- inputfiles/patches/indexeddb.kdl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inputfiles/patches/indexeddb.kdl b/inputfiles/patches/indexeddb.kdl index 01c675cd3..b11fc6ab4 100644 --- a/inputfiles/patches/indexeddb.kdl +++ b/inputfiles/patches/indexeddb.kdl @@ -1,7 +1,7 @@ interface IDBRequest { + typeParameters T default=any property source { - type "" nullable=#false + type nullable=#false } property result overrideType=T - typeParameters T default=any } From 492b3b429124063fcc4c4bae6a3c7b907c6224ae Mon Sep 17 00:00:00 2001 From: Bashamega Date: Mon, 15 Dec 2025 15:50:13 +0200 Subject: [PATCH 10/10] Supports opptinal name --- src/build/patches.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/build/patches.ts b/src/build/patches.ts index bf0550a7f..26368e585 100644 --- a/src/build/patches.ts +++ b/src/build/patches.ts @@ -48,16 +48,15 @@ function string(arg: unknown): string { return arg; } -function handleTyped(type: Node): Typed { +function handleTyped(type: Node): DeepPartial { const isTyped = type.name == "type"; if (!isTyped) { throw new Error("Expected a type node"); } - const name = string(type.values[0]); const subType = type.children.length > 0 ? handleTyped(type.children[0]) : undefined; return { - type: name, + ...optionalMember("type", "string", type.values[0]), subtype: subType, ...optionalMember("nullable", "boolean", type.properties?.nullable), }; @@ -167,7 +166,7 @@ function handleMixinAndInterfaces( const name = string(node.properties?.name || node.values[0]); const event: Event[] = []; - const property: Record> = {}; + const property: Record> = {}; let method: Record> = {}; let typeParameters = {}; @@ -246,7 +245,7 @@ function handleEvent(child: Node): Event { * Handles a child node of type "property" and adds it to the property object. * @param child The child node to handle. */ -function handleProperty(child: Node): Partial { +function handleProperty(child: Node): DeepPartial { let typeNode: Node | undefined; for (const c of child.children) { if (c.name === "type") {