Open jrencz opened 1 year ago
I think I'm running in to this issue as well.
I get a similar error message, apparently it is related to enums:
TypeError: Cannot read properties of undefined (reading 'kind')
at Object.isEnumDeclaration (./.yarn/cache/typescript-patch-97a611e52a-f5481fa3ba.zip/node_modules/typescript/lib/typescript.js:26316:17)
at TypeofNodeParser.createType (./.yarn/cache/ts-json-schema-generator-npm-1.3.0-e61e0429c2-4d4ca009a3.zip/node_modules/ts-json-schema-generator/dist/src/NodeParser/TypeofNodeParser.js:28:34)
at ChainNodeParser.createType (./.yarn/cache/ts-json-schema-generator-npm-1.3.0-e61e0429c2-4d4ca009a3.zip/node_modules/ts-json-schema-generator/dist/src/ChainNodeParser.js:28:54)
at ./.yarn/cache/ts-json-schema-generator-npm-1.3.0-e61e0429c2-4d4ca009a3.zip/node_modules/ts-json-schema-generator/dist/src/NodeParser/IntersectionNodeParser.js:24:72
at Array.map (<anonymous>)
at IntersectionNodeParser.createType (./.yarn/cache/ts-json-schema-generator-npm-1.3.0-e61e0429c2-4d4ca009a3.zip/node_modules/ts-json-schema-generator/dist/src/NodeParser/IntersectionNodeParser.js:24:34)
at ChainNodeParser.createType (./.yarn/cache/ts-json-schema-generator-npm-1.3.0-e61e0429c2-4d4ca009a3.zip/node_modules/ts-json-schema-generator/dist/src/ChainNodeParser.js:28:54)
at AnnotatedNodeParser.createType (./.yarn/cache/ts-json-schema-generator-npm-1.3.0-e61e0429c2-4d4ca009a3.zip/node_modules/ts-json-schema-generator/dist/src/NodeParser/AnnotatedNodeParser.js:30:47)
at ./.yarn/cache/ts-json-schema-generator-npm-1.3.0-e61e0429c2-4d4ca009a3.zip/node_modules/ts-json-schema-generator/dist/src/NodeParser/InterfaceAndClassNodeParser.js:103:134
at Array.map (<anonymous>)
Also running into this issue when generating a type that uses Microsoft's Monaco Editor's types since it references HTMLElement
.
Thanks for the bug report. Would you like to start a PR? I'm happy to review it
Hi,
I actually phased out the ts type
->jsonschema
approach in my project in favour of metamodel
->(jsonschema, ts type)
with Typebox.
That approch is a bit more complex, but when my project started scaling up I observed not only behavior like one reported here, but also generation times increasing. Since I do own the types and I can just rewrite them, I decided to do so. It may not be an option everywhere
Probably this issue could be resolved by just adding --tsconfig ./tsconfig.json
to correctly load all types.
I'll further investigate this once I have time.
In one of my types I have references to native interfaces that come with typescript, let's say:
(Type is a bit more complex, but I boiled it down to parts that cause problem)
When I try to generate schema out of this file I get the following error:
If I replace the references to
HTMLFormElement
with their actual values (in both cases it'sstring
) I get the correct schema:I also get a correct schema when I replicate the part of
HTMLFormElement
in module exporting typeMyForm
:It's (AFAIK) impossible to import those built-in types explicitly