pydantic-to-typescript icon indicating copy to clipboard operation
pydantic-to-typescript copied to clipboard

Support inheritance when generating TS interfaces

Open guaycuru opened this issue 1 year ago • 2 comments

Currently if I have

class ChildClass(ParentClass):
  something: str

class ParentClass(BaseModel):
  anything: str

The generated output is:

export interface ChildClass {
  something: string;
  anything: string;
}

export interface ParentClass {
  anything: string;
}

When a better output would be:

export interface ChildClass extends ParentClass {
  something: string;
}

export interface ParentClass {
  anything: string;
}

It seems https://github.com/bcherny/json-schema-to-typescript supports this. See this example.

guaycuru avatar Oct 10 '24 13:10 guaycuru