py2ts.data.TSComplex

class py2ts.data.TSComplex(name: str, *, not_required: bool = False, comment: str | None = None)

Represents a TypeScript complex type.

This is an abstract class that is used as a base class for more complex types such as interfaces and enums.

We assume the name is unique for each complex type therefore we use it as the hash.

Attributes

comment

not_required

name

Methods

__init__(name, *[, not_required, comment])

exclude(exclude)

Exclude fields from the type.

referenced_types()

Get all TypeScript types required for the current type.

__init__(name: str, *, not_required: bool = False, comment: str | None = None) None
exclude(exclude: set[str]) Self

Exclude fields from the type.

Parameters:

exclude (set[str]) – A set of field names to exclude from the TypeScript interface.

Returns:

The modified type with the excluded fields.

Return type:

TypescriptType

referenced_types() set[TypescriptType]

Get all TypeScript types required for the current type.

This method should gather all the necessary types and dependencies related to the current type, aiding in understanding and organizing generated code where multiple type inter-dependencies exist.