bcherny/json-schema-to-typescript
View on GitHubIs it possible to extend custom types?
Open
#211 opened on Jan 7, 2019
buggood first issuehelp wanted
Repository metrics
- Stars
- (3,302 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
This is a use case that I have:
{
"title": "ILinkProps",
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"extends": {
"$ref": "#/definitions/anchor"
},
"properties": {
"visited": {
"type": "boolean"
},
"external": {
"type": "boolean"
},
"icon": {
"type": "boolean"
},
"to": {
"type": "string"
},
"component": {
"$ref": "#/definitions/component"
}
},
"definitions": {
"component": {
"tsType": "React.ComponentClass | React.SFC"
},
"anchor": {
"title": "Anchor",
"tsType": "React.AnchorHTMLAttributes<HTMLAnchorElement>"
}
},
"additionalProperties": false
}
Expected Output:
export type Component = React.ComponentClass | React.SFC;
export type Anchor = React.AnchorHTMLAttributes<HTMLAnchorElement>;
export interface ILinkProps extends Anchor {
visited?: boolean;
external?: boolean;
icon?: boolean;
to?: string;
component?: Component;
}
What I get instead:
export type Component = React.ComponentClass | React.SFC;
export interface ILinkProps extends Anchor {
visited?: boolean;
external?: boolean;
icon?: boolean;
to?: string;
component?: Component;
}
export interface Anchor {
[k: string]: any;
}
Is it possible to have the generated interface extend custom types?