Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LogicError: No additional properties in type #136

Closed
muzea opened this issue Jun 21, 2019 · 4 comments · Fixed by #139
Closed

LogicError: No additional properties in type #136

muzea opened this issue Jun 21, 2019 · 4 comments · Fixed by #139

Comments

@muzea
Copy link

muzea commented Jun 21, 2019

Step to reproduce:

yarn global add ts-json-schema-generator
yarn global add antd@3.19.6
cd `yarn global dir`/node_modules/antd
ts-json-schema-generator --path es/form/index.d.ts --type 'Form' --expose 'none' --jsDoc 'none' --no-type-check --no-top-ref

Will receive an error

LogicError: No additional properties in type "["horizontal","inline","vertical"]"
@kayahr
Copy link
Contributor

kayahr commented Jun 21, 2019

You are trying to create a JSON schema for a class which is extending React.Component. Are you sure that's what you want to do? What sense does it make to have a JSON schema for such a type?

Anyway, the extracted problematic code is actually this:

declare const FormLayouts: ["horizontal", "inline", "vertical"];
export declare type FormLayout = (typeof FormLayouts)[number];

Generating the schema for type FormLayout fails.

@kayahr
Copy link
Contributor

kayahr commented Jun 21, 2019

PR #139 will fix this problem.

But even with this you will not be able to create a JSON schema for this complex Form class. The next problematic part will be this interesting type:

type EventHandler<E extends SyntheticEvent<any>> = { bivarianceHack(event: E): void }["bivarianceHack"];

So this is actually a function type and functions are not supported in JSON and therefor out-of-scope for a JSON schema generator.

@muzea
Copy link
Author

muzea commented Jun 23, 2019

@kayahr
Last week, I was trying to use type information to determine which version of an api was added. Want to provide a script that can automatically modify the documentation for Update website APIs to show version Number features were added.

@545682879
Copy link

545682879 commented Jun 19, 2020

when I run

yarn global add ts-json-schema-generator
yarn global add antd@3.19.6
cd `yarn global dir`/node_modules/antd
ts-json-schema-generator --path es/form/index.d.ts --type 'Form' --expose 'none' --jsDoc 'none' --no-type-check --no-top-ref

it raise error:

/Users/vivichen/.config/yarn/global/node_modules/ts-json-schema-generator/dist/ts-json-schema-generator.js:45
        throw error;
        ^

TypeError: Cannot read property 'kind' of undefined
  at Object.isEnumDeclaration (/Users/vivichen/.config/yarn/global/node_modules/ts-json-schema-generator/node_modules/typescript/lib/typescript.js:11757:21)
    at TypeofNodeParser.createType (/Users/vivichen/.config/yarn/global/node_modules/ts-json-schema-generator/dist/src/NodeParser/TypeofNodeParser.js:23:16)
    at ChainNodeParser.createType (/Users/vivichen/.config/yarn/global/node_modules/ts-json-schema-generator/dist/src/ChainNodeParser.js:28:54)
    at /Users/vivichen/.config/yarn/global/node_modules/ts-json-schema-generator/dist/src/NodeParser/IntersectionNodeParser.js:17:72
    at Array.map (<anonymous>)
    at IntersectionNodeParser.createType (/Users/vivichen/.config/yarn/global/node_modules/ts-json-schema-generator/dist/src/NodeParser/IntersectionNodeParser.js:17:34)
    at ChainNodeParser.createType (/Users/vivichen/.config/yarn/global/node_modules/ts-json-schema-generator/dist/src/ChainNodeParser.js:28:54)
    at /Users/vivichen/.config/yarn/global/node_modules/ts-json-schema-generator/dist/src/NodeParser/InterfaceAndClassNodeParser.js:95:106
    at Array.map (<anonymous>)
    at InterfaceAndClassNodeParser.getProperties (/Users/vivichen/.config/yarn/global/node_modules/ts-json-schema-generator/dist/src/NodeParser/InterfaceAndClassNodeParser.js:95:14)

do you know why? thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants