Skip to main content

Convert Python types to TypeScript

Project description

typtyp

Convert Python types and type annotations to TypeScript type definitions.

Features

  • Convert dataclasses, TypedDict, enums, and Pydantic models to TypeScript
  • Support for Python's standard typing primitives
  • Rich type support (dates, UUIDs, complex collections, etc.)
  • Simple API for declaring types for conversion

Installation

pip install typtyp

Usage

from dataclasses import dataclass
from typing import List, Optional
import typtyp

@dataclass
class User:
    name: str
    email: str
    age: Optional[int] = None

@dataclass
class Team:
    name: str
    members: List[User]

# Create a world to collect types
world = typtyp.World()

# Add types to the world
world.add(User)
world.add(Team)

# Generate TypeScript
typescript_code = world.get_typescript()
print(typescript_code)

Output (approximately – you would want to run typtyp's output through a formatter of your liking):

export interface User {
  name: string;
  email: string;
  age: number | null;
}

export interface Team {
  name: string;
  members: User[];
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

typtyp-0.1.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

typtyp-0.1.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file typtyp-0.1.0.tar.gz.

File metadata

  • Download URL: typtyp-0.1.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for typtyp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f3cbca2b87c1de77a58f1f30e5e4e3f7af8714585730228167c8524d53fadb4b
MD5 c8b396d59d87faeb7c02b7dd7235ceb5
BLAKE2b-256 5f7c18c3eb5b69c4fe069c32f050522aff923b91f8764d9d64cd3257b49b397b

See more details on using hashes here.

Provenance

The following attestation bundles were made for typtyp-0.1.0.tar.gz:

Publisher: ci.yml on akx/typtyp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file typtyp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: typtyp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for typtyp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dbc2cf75d9b8ca4112e3a7923abfc28196185a25c36116522a18ce5451269191
MD5 2bf541d955afdcdac495831f87446d9c
BLAKE2b-256 edfbcfae4ff4d02e00c8400709d1f0a05ab8844019e3ae10c57fabd2c4cd77f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for typtyp-0.1.0-py3-none-any.whl:

Publisher: ci.yml on akx/typtyp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page