typescript-json-schema
typescript-json-schema copied to clipboard
Support for mapped types?
Hi,
Does this library support mapped types?
The following example suggests it does not:
// Type mapper to construct a type from another type, where all properties are made nullable
export type Nullable<Type> = {
[Property in keyof Type]: Type[Property] | null
}
export type A = {
a: string
}
export type B = Nullable<A>
$ yarn run --silent typescript-json-schema test.ts B
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"a": {
"type": "string"
}
},
"type": "object"
}
The expected type for the a property should be a type union with null.
Thanks a lot :)
It probably does not but vega/ts-json-schema-generator does.