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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3cbca2b87c1de77a58f1f30e5e4e3f7af8714585730228167c8524d53fadb4b
|
|
| MD5 |
c8b396d59d87faeb7c02b7dd7235ceb5
|
|
| BLAKE2b-256 |
5f7c18c3eb5b69c4fe069c32f050522aff923b91f8764d9d64cd3257b49b397b
|
Provenance
The following attestation bundles were made for typtyp-0.1.0.tar.gz:
Publisher:
ci.yml on akx/typtyp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typtyp-0.1.0.tar.gz -
Subject digest:
f3cbca2b87c1de77a58f1f30e5e4e3f7af8714585730228167c8524d53fadb4b - Sigstore transparency entry: 188179339
- Sigstore integration time:
-
Permalink:
akx/typtyp@7335827a349c254d27e5af01bea085a93c44d730 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/akx
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@7335827a349c254d27e5af01bea085a93c44d730 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbc2cf75d9b8ca4112e3a7923abfc28196185a25c36116522a18ce5451269191
|
|
| MD5 |
2bf541d955afdcdac495831f87446d9c
|
|
| BLAKE2b-256 |
edfbcfae4ff4d02e00c8400709d1f0a05ab8844019e3ae10c57fabd2c4cd77f9
|
Provenance
The following attestation bundles were made for typtyp-0.1.0-py3-none-any.whl:
Publisher:
ci.yml on akx/typtyp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typtyp-0.1.0-py3-none-any.whl -
Subject digest:
dbc2cf75d9b8ca4112e3a7923abfc28196185a25c36116522a18ce5451269191 - Sigstore transparency entry: 188179340
- Sigstore integration time:
-
Permalink:
akx/typtyp@7335827a349c254d27e5af01bea085a93c44d730 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/akx
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@7335827a349c254d27e5af01bea085a93c44d730 -
Trigger Event:
push
-
Statement type: