From 1c26502130fb6523e9567310931de5f812cc21db Mon Sep 17 00:00:00 2001 From: Bashamega Date: Sat, 10 Jan 2026 09:56:41 +0200 Subject: [PATCH 1/3] Support records in KDL --- inputfiles/addedTypes.jsonc | 13 ------------- inputfiles/patches/wasm-js-api.kdl | 6 ++++++ src/build/patches.ts | 8 ++++++-- 3 files changed, 12 insertions(+), 15 deletions(-) create mode 100644 inputfiles/patches/wasm-js-api.kdl diff --git a/inputfiles/addedTypes.jsonc b/inputfiles/addedTypes.jsonc index 64861d798..b69899a60 100644 --- a/inputfiles/addedTypes.jsonc +++ b/inputfiles/addedTypes.jsonc @@ -425,19 +425,6 @@ "legacyNamespace": "WebAssembly", "overrideType": "Function | Global | Memory | Table" }, - { - "name": "Exports", - "legacyNamespace": "WebAssembly", - "type": "record", - "subtype": [ - { - "type": "DOMString" - }, - { - "type": "ExportValue" - } - ] - }, { "name": "ModuleImports", "legacyNamespace": "WebAssembly", diff --git a/inputfiles/patches/wasm-js-api.kdl b/inputfiles/patches/wasm-js-api.kdl new file mode 100644 index 000000000..969df3846 --- /dev/null +++ b/inputfiles/patches/wasm-js-api.kdl @@ -0,0 +1,6 @@ +typedef Exports legacyNamespace=WebAssembly { + type record { + type DOMString + type ExportValue + } +} \ No newline at end of file diff --git a/src/build/patches.ts b/src/build/patches.ts index ac72d1742..d8d178534 100644 --- a/src/build/patches.ts +++ b/src/build/patches.ts @@ -59,11 +59,15 @@ function handleSingleTypeNode(type: Node): DeepPartial { if (!isTyped) { throw new Error("Expected a type node"); } + const typeValue = type.values[0]; const subType = type.children.length > 0 ? handleTyped(type.children) : undefined; return { - ...optionalMember("type", "string", type.values[0]), - subtype: subType, + ...optionalMember("type", "string", typeValue), + subtype: + typeValue == "record" && typeof subType?.type !== "string" + ? subType?.type + : subType, ...optionalMember("nullable", "boolean", type.properties?.nullable), }; } From ac3e8198c1d8f24f77dde62e073c877fa287675b Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Sat, 10 Jan 2026 20:35:51 +0100 Subject: [PATCH 2/3] reindent --- inputfiles/patches/wasm-js-api.kdl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/inputfiles/patches/wasm-js-api.kdl b/inputfiles/patches/wasm-js-api.kdl index 969df3846..867f64783 100644 --- a/inputfiles/patches/wasm-js-api.kdl +++ b/inputfiles/patches/wasm-js-api.kdl @@ -1,6 +1,6 @@ typedef Exports legacyNamespace=WebAssembly { - type record { - type DOMString - type ExportValue - } -} \ No newline at end of file + type record { + type DOMString + type ExportValue + } +} From 48b14209a8c6c77e80aab44a51f47fcbd7a854b9 Mon Sep 17 00:00:00 2001 From: Bashamega Date: Sun, 11 Jan 2026 14:02:25 +0200 Subject: [PATCH 3/3] Add isUnion --- inputfiles/patches/wasm-js-api.kdl | 2 +- src/build/patches.ts | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/inputfiles/patches/wasm-js-api.kdl b/inputfiles/patches/wasm-js-api.kdl index 867f64783..8ec4446c7 100644 --- a/inputfiles/patches/wasm-js-api.kdl +++ b/inputfiles/patches/wasm-js-api.kdl @@ -1,5 +1,5 @@ typedef Exports legacyNamespace=WebAssembly { - type record { + type record union=#true { type DOMString type ExportValue } diff --git a/src/build/patches.ts b/src/build/patches.ts index d8d178534..50e15d318 100644 --- a/src/build/patches.ts +++ b/src/build/patches.ts @@ -62,12 +62,11 @@ function handleSingleTypeNode(type: Node): DeepPartial { const typeValue = type.values[0]; const subType = type.children.length > 0 ? handleTyped(type.children) : undefined; + const isUnion = typeof type.properties.union == "boolean"; return { ...optionalMember("type", "string", typeValue), subtype: - typeValue == "record" && typeof subType?.type !== "string" - ? subType?.type - : subType, + isUnion && typeof subType?.type !== "string" ? subType?.type : subType, ...optionalMember("nullable", "boolean", type.properties?.nullable), }; }