YousefED / typescript-json-schema

Generate json-schema from your Typescript sources
BSD 3-Clause "New" or "Revised" License
3.17k stars 323 forks source link

How to support type inference? #500

Open tangkai123456 opened 2 years ago

tangkai123456 commented 2 years ago

Demo

https://github.com/tangkai123456/schema-demo

Type file:

function fn1({ a = '' }) {

}

type Params = Parameters<typeof fn1>

Error

TypeError: Unsupported type: { a?: string | undefined; }
    at JsonSchemaGenerator.getDefinitionForRootType (/Users/bj-51-60-1205/Desktop/learn/schema-demo/node_modules/typescript-json-schema/dist/typescript-json-schema.js:497:33)
    at JsonSchemaGenerator.getTypeDefinition (/Users/bj-51-60-1205/Desktop/learn/schema-demo/node_modules/typescript-json-schema/dist/typescript-json-schema.js:1028:26)
    at /Users/bj-51-60-1205/Desktop/learn/schema-demo/node_modules/typescript-json-schema/dist/typescript-json-schema.js:425:77