typescript-json-schema icon indicating copy to clipboard operation
typescript-json-schema copied to clipboard

Support for mapped types?

Open bertrand-caron opened this issue 4 years ago • 1 comments

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 :)

bertrand-caron avatar Oct 20 '21 07:10 bertrand-caron

It probably does not but vega/ts-json-schema-generator does.

domoritz avatar Oct 20 '21 14:10 domoritz