diff --git a/src/generate-types.ts b/src/generate-types.ts index a254237..cde9f55 100644 --- a/src/generate-types.ts +++ b/src/generate-types.ts @@ -24,8 +24,9 @@ function normalizeAttributeType(attrType: string): string { // string if (/EventHandler/i.test(attrType)) return "string"; - // vhtml doesn't have a distinct node type--all components become strings. - if (attrType === "ReactNode") return "string"; + // vhtml doesn't have a distinct node type--the serializer accepts any value. + // (arrays of any depth are flattened and concatenated) + if (attrType === "ReactNode") return "any"; // vhtml doesn't convert style objects to string, so CSSProperties isn't // supported. @@ -262,6 +263,9 @@ function generateJsxTypesForVhtml( // A functional pseudo-component returns a string as "element" writer.writeLine(`type Element = string;`); + // Enable strict type checking for children (TypeScript 2.3+) + writer.writeLine(`interface ElementChildrenAttribute { children: {}; }`); + writer.writeLine(intrinsicElementsInterface.getText()); extractedInterfaceNodes.forEach((node) => { // If the interface has no properties, convert it to a type alias, using