From fd879609a3bd25e29580a000e8a5fc7697496688 Mon Sep 17 00:00:00 2001 From: Bashamega Date: Tue, 9 Dec 2025 13:27:41 +0200 Subject: [PATCH 1/2] Support removing enums --- inputfiles/patches/html.kdl | 4 ++++ inputfiles/removedTypes.jsonc | 5 ----- src/build/patches.ts | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/inputfiles/patches/html.kdl b/inputfiles/patches/html.kdl index ff4b3c1c1..3b7f707dd 100644 --- a/inputfiles/patches/html.kdl +++ b/inputfiles/patches/html.kdl @@ -23,3 +23,7 @@ interface NavigationPrecommitController exposed=Window { interface NavigationTransition { property committed exposed=Window } + +removals { + enum ValueType +} diff --git a/inputfiles/removedTypes.jsonc b/inputfiles/removedTypes.jsonc index 06cd05c7d..086219910 100644 --- a/inputfiles/removedTypes.jsonc +++ b/inputfiles/removedTypes.jsonc @@ -11,11 +11,6 @@ } } }, - "enums": { - "enum": { - "ValueType": null - } - }, "interfaces": { "interface": { "Clipboard": { diff --git a/src/build/patches.ts b/src/build/patches.ts index 0bf053af7..4917afd77 100644 --- a/src/build/patches.ts +++ b/src/build/patches.ts @@ -89,7 +89,7 @@ function optionalNestedMember(prop: string, object: object, output: T) { * Converts parsed KDL Document nodes to match the [types](types.d.ts). */ function convertKDLNodes(nodes: Node[]): DeepPartial { - const enums: Record = {}; + const enums: Record> = {}; const mixin: Record> = {}; const interfaces: Record> = {}; const dictionary: Record> = {}; @@ -134,7 +134,7 @@ function convertKDLNodes(nodes: Node[]): DeepPartial { * @param node The enum node to handle. * @param enums The record of enums to update. */ -function handleEnum(node: Node): Enum { +function handleEnum(node: Node): Partial { const name = string(node.properties?.name || node.values[0]); const values: string[] = []; @@ -144,7 +144,7 @@ function handleEnum(node: Node): Enum { return { name, - value: values, + ...(values.length > 0 ? { value: values } : {}), ...optionalMember( "legacyNamespace", "string", From b0ee6a1de6140bb36f4bb1809db80ae8f44cfac6 Mon Sep 17 00:00:00 2001 From: Bashamega Date: Wed, 10 Dec 2025 06:38:49 +0200 Subject: [PATCH 2/2] Use optionalNestedMember function --- 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 4917afd77..be6873777 100644 --- a/src/build/patches.ts +++ b/src/build/patches.ts @@ -144,7 +144,7 @@ function handleEnum(node: Node): Partial { return { name, - ...(values.length > 0 ? { value: values } : {}), + ...optionalNestedMember("value", values, values), ...optionalMember( "legacyNamespace", "string",