From 3ac6706800a263e6629f051d40e279f422557217 Mon Sep 17 00:00:00 2001 From: EthanThatOneKid <31261035+EthanThatOneKid@users.noreply.github.com> Date: Fri, 5 Apr 2024 17:09:04 -0700 Subject: [PATCH] Update codegen.ts --- cli/codegen.ts | 69 ++++++++++++++++++++------------------------------ 1 file changed, 27 insertions(+), 42 deletions(-) diff --git a/cli/codegen.ts b/cli/codegen.ts index 6b28e7c..a57c278 100644 --- a/cli/codegen.ts +++ b/cli/codegen.ts @@ -136,48 +136,33 @@ if (import.meta.main) { }); // Add an interface for the props. - if (descriptor.attrs.length > 0) { - sourceFile.addInterface({ - name: descriptor.propsInterfaceName, - isExported: true, - extends: ["GlobalAttributes"], - docs: toDocs({ - description: - `${descriptor.propsInterfaceName} are the props for the [\`${descriptor.tag}\`](${descriptor.see}) element.`, - see: descriptor.see, - isDeprecated: descriptor.isDeprecated, - isExperimental: descriptor.isExperimental, - }), - properties: descriptor.attrs.map((attr) => { - return { - name: attr.includes("-") ? `'${attr}'` : attr, - hasQuestionToken: true, - type: "string | undefined", - docs: toDocs({ - description: - `\`${attr}\` is an attribute of the [\`${descriptor.tag}\`](${descriptor.see}) element.`, - isExperimental: bcd.html.elements[descriptor.tag][attr].__compat - ?.status?.experimental, - isDeprecated: bcd.html.elements[descriptor.tag][attr].__compat - ?.status?.deprecated, - }), - }; - }), - }); - } else { - sourceFile.addInterface({ - name: descriptor.propsInterfaceName, - isExported: true, - extends: ["GlobalAttributes"], - docs: toDocs({ - description: - `${descriptor.propsInterfaceName} are the props for the [\`${descriptor.tag}\`](${descriptor.see}) element.`, - see: descriptor.see, - isDeprecated: descriptor.isDeprecated, - isExperimental: descriptor.isExperimental, - }), - }); - } + sourceFile.addInterface({ + name: descriptor.propsInterfaceName, + isExported: true, + extends: ["GlobalAttributes"], + docs: toDocs({ + description: + `${descriptor.propsInterfaceName} are the props for the [\`${descriptor.tag}\`](${descriptor.see}) element.`, + see: descriptor.see, + isDeprecated: descriptor.isDeprecated, + isExperimental: descriptor.isExperimental, + }), + properties: descriptor.attrs.map((attr) => { + return { + name: attr.includes("-") ? `'${attr}'` : attr, + hasQuestionToken: true, + type: "string | undefined", + docs: toDocs({ + description: + `\`${attr}\` is an attribute of the [\`${descriptor.tag}\`](${descriptor.see}) element.`, + isExperimental: bcd.html.elements[descriptor.tag][attr].__compat + ?.status?.experimental, + isDeprecated: bcd.html.elements[descriptor.tag][attr].__compat + ?.status?.deprecated, + }), + }; + }), + }); // Add the element render function. sourceFile.addFunction({