Skip to content

Commit

Permalink
Update codegen.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanThatOneKid committed Apr 6, 2024
1 parent 74380ba commit 3ac6706
Showing 1 changed file with 27 additions and 42 deletions.
69 changes: 27 additions & 42 deletions cli/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 3ac6706

Please sign in to comment.