py2ts.data

Data structures used in the code generation process.

This module defines the data structures used to represent TypeScript types and interfaces.

Functions

ts_reference_str(elements[, ignore])

Return a string representation of all interfaces and enums in the elements.

Classes

DerivedType(elements, *[, not_required, comment])

Represents a TypeScript derived type.

TSArrayType(elements, *[, not_required, comment])

Represents a TypeScript array type.

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

Represents a TypeScript complex type.

TSEnumType(name, elements, *[, ...])

Represents a TypeScript enum type.

TSInterface(name, elements[, inheritance, ...])

Represents a TypeScript interface.

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

Represents a TypeScript interface reference.

TSLiteralType(value, *[, not_required, comment])

Represents a TypeScript literal type.

TSPrimitiveType(type, *[, not_required, comment])

Represents a TypeScript primitive type.

TSRecordType(key, value)

Represents a TypeScript record type.

TSTupleType(elements, *[, not_required, comment])

Represents a TypeScript tuple type.

TSUnionType(elements, *[, not_required, comment])

Represents a TypeScript union type.

TypescriptIntersectionType(elements, *[, ...])

Represents a TypeScript intersection type.

TypescriptPrimitive(value)

Represents a TypeScript primitive type.

TypescriptType(*[, not_required, comment])

Represents a TypeScript type.

Module Functions

py2ts.data.ts_reference_str(elements: Iterable[TypescriptType], ignore=[]) str

Return a string representation of all interfaces and enums in the elements.

Resolves nested types and returns a string representation of all interfaces and enums in the elements.

Can be used to create the typescript definitions as strings when generating code.

Parameters:
  • elements (Iterable[TypescriptType]) – The elements to be resolved.

  • ignore (List[TypescriptType], optional) – A list of types to ignore, by default [].

Returns:

The string representation of all interfaces and enums in the elements.

Return type:

str