🌐
GitHub
github.com › TheLartians › TypeScript2Python
GitHub - TheLartians/TypeScript2Python: 🚃 Transpile TypeScript types to Python! A TypeScript to Python type transpiler.
🚃 Transpile TypeScript types to Python! A TypeScript to Python type transpiler. - TheLartians/TypeScript2Python
Starred by 27 users
Forked by 3 users
Languages   TypeScript 91.3% | JavaScript 8.7%
🌐
GitHub
github.com › marcj › pybridge
GitHub - marcj/pybridge: TypeScript library to access python functions in NodeJS, type-safe and easy to use. · GitHub
TypeScript library to access python functions in NodeJS, type-safe and easy to use. - marcj/pybridge
Starred by 82 users
Forked by 10 users
Languages   TypeScript 98.1% | Python 1.9%
Discussions

Are there any tools to transform a large Typescript project into Python? Maybe a transpiler or something?
There are at least two big issues with this: Semantics: Javascript and Python are similar, being dynamic, garbage collected languages. But there is an incredible amount of subtlety to the way both languages behave. You'd end up needing to write your own runtime library to emulate javascript, which is known for many weird quirks. Maybe you could accomplish in a way where the resulting code is readable, but everything would still rely on your support library which provides non-standard behaviors for everything. Libraries: Both languages are known for their rich ecosystems. What libraries does your project use? Maybe you could compile the libraries as well, but what if they're native bindings? At minimum, you'd almost certainly need to provide some emulation for node/deno/bun/whatever runtime you're using. More on reddit.com
🌐 r/Compilers
6
0
May 29, 2025
Python equivalent of Typescript interface - Stack Overflow
For the code completion and type hinting in IDEs, just add static typing for the Person and Address classes and you are already good to go. Assuming you use the latest python3.6, here's a rough equivalent of the typescript classes from your example: More on stackoverflow.com
🌐 stackoverflow.com
Side project for converting Python into TypeScript
I definitely recommend you get rid of all of the any types that it outputs. Even if it is just meant as a placeholder, it’s actually worse than not having anything there, because Typescript won’t try to infer the types. In effect, it becomes just JavaScript with pointless Typescript syntax. More on reddit.com
🌐 r/typescript
43
106
December 26, 2020
Performance difference between Python and Typescript
I ran a benchmark deploying a Helm chart with Pulumi, using two languages: Python and Typescript. It seems that Typescript is quite a bit faster than the Python implementation. I just upped and des... More on github.com
🌐 github.com
3
February 10, 2021
🌐
GitHub
github.com › Madoshakalaka › python-typing-to-typescript
GitHub - Madoshakalaka/python-typing-to-typescript: convert python typing to interface · GitHub
The program parses Python script with Python's built-in ast, and uses typescript's compiler APIs to transform the ast nodes.
Author   Madoshakalaka
🌐
GitHub
github.com › cs-cordero › py-ts-interfaces
GitHub - cs-cordero/py-ts-interfaces: A Python to Typescript Interface Generator · GitHub
July 1, 2024 - Generally speaking, you can express any type that Python can do in TypeScript, but not vice versa. So defining the types in Python guarantee that you can also express the whole interface in both languages. Please note that usage of T U and V in the table below represent stand-ins for actual types. They do not represent actually using generic typed variables. ... The primary purpose of this library is to help type, first and foremost, data moving back and forth from client to server.
Starred by 111 users
Forked by 12 users
Languages   Python 99.1% | Shell 0.9%
🌐
GitHub
github.blog › home › news & insights › octoverse › typescript, python, and the ai feedback loop changing software development
TypeScript, Python, and the AI feedback loop changing software development - The GitHub Blog
November 13, 2025 - TypeScript passed Python. But the real story is why. Developers don’t usually switch languages just for philosophical reasons—they switch when something makes their work meaningfully faster, simpler, or less risky. And increasingly, what feels “easier” is tied to how well AI tools will support their work with that language.
🌐
Reddit
reddit.com › r/compilers › are there any tools to transform a large typescript project into python? maybe a transpiler or something?
r/Compilers on Reddit: Are there any tools to transform a large Typescript project into Python? Maybe a transpiler or something?
May 29, 2025 - It‘s everywhere in JS and almost nonexistant in Python. ... Your only chance is using LLMs. Good luck, hope you have a ton of unit tests. ... They became really good recently though. Deepsake from yesterday is even free ... I use a good amount of LLMs for carefully chosen tasks. I trust it about as much as a slightly experienced intern. I wouldn't trust an intern to port a typescript codebase to python.
Find elsewhere
🌐
GitHub
github.com › jecki › ts2python
GitHub - jecki/ts2python: Python-interoperability for Typescript-Interfaces · GitHub
June 19, 2014 - Python-interoperability for Typescript-Interfaces. Contribute to jecki/ts2python development by creating an account on GitHub.
Starred by 51 users
Forked by 5 users
Languages   Python
Top answer
1 of 9
61

For the code completion and type hinting in IDEs, just add static typing for the Person and Address classes and you are already good to go. Assuming you use the latest python3.6, here's a rough equivalent of the typescript classes from your example:

# spam.py
from typing import Optional, Sequence


class Address:
    street: str
    housenumber: int
    housenumber_postfix: Optional[str]

    def __init__(self, street: str, housenumber: int, 
                 housenumber_postfix: Optional[str] = None) -> None:
        self.street = street
        self.housenumber = housenumber
        self.housenumber_postfix = housenumber_postfix


class Person:
    name: str
    adresses: Sequence[Address]

    def __init__(self, name: str, adresses: Sequence[str]) -> None:
        self.name = name
        self.adresses = adresses


person = Person('Joe', [
    Address('Sesame', 1), 
    Address('Baker', 221, housenumber_postfix='b')
])  # type: Person

I suppose the boilerplate you mentioned emerges when adding the class constructors. This is indeed inavoidable. I would wish default constructors were generated at runtime when not declared explicitly, like this:

class Address:
    street: str
    housenumber: int
    housenumber_postfix: Optional[str]


class Person:
    name: str
    adresses: Sequence[Address]


if __name__ == '__main__':
    alice = Person('Alice', [Address('spam', 1, housenumber_postfix='eggs')])
    bob = Person('Bob', ())  # a tuple is also a sequence

but unfortunately you have to declare them manually.


Edit

As Michael0x2a pointed out in the comment, the need for default constructors is made avoidable in python3.7 which introduced a @dataclass decorator, so one can indeed declare:

@dataclass
class Address:
    street: str
    housenumber: int
    housenumber_postfix: Optional[str]


@dataclass
class Person:
    name: str
    adresses: Sequence[Address]

and get the default impl of several methods, reducing the amount of boilerplate code. Check out PEP 557 for more details.


I guess you could see stub files that can be generated from your code, as some kind of interface files:

$ stubgen spam  # stubgen tool is part of mypy package
Created out/spam.pyi

The generated stub file contains the typed signatures of all non-private classes and functions of the module without implementation:

# Stubs for spam (Python 3.6)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Optional, Sequence

class Address:
    street: str
    housenumber: int
    housenumber_postfix: Optional[str]
    def __init__(self, street: str, housenumber: int, housenumber_postfix: Optional[str]=...) -> None: ...

class Person:
    name: str
    adresses: Sequence[Address]
    def __init__(self, name: str, adresses: Sequence[str]) -> None: ...

person: Person

These stub files are also recognized by IDEs and if your original module is not statically typed, they will use the stub file for type hints and code completion.

2 of 9
24

A TypeScript interface describes a JavaScript object. Such an object is analogous to a Python dictionary with well-known string keys, which is described by a TypedDict.

TypeScript interface example

For example the TypeScript interface:

interface Address {
    street: string;
    housenumber: number;
}

will describe JavaScript objects like:

var someAddress = {
    street: 'SW Gemini Dr.',
    housenumber: 9450,
};

Python TypedDict example

The equivalent Python TypedDict:

from typing import TypedDict

class Address(TypedDict):
    street: str
    housenumber: int

will describe Python dictionaries like:

some_address = {
    'street': 'SW Gemini Dr.',
    'housenumber': 9450,
}

# or equivalently:

some_address = dict(
    street='SW Gemini Dr.',
    housenumber=9450,
)

These dictionaries can be serialized to/from JSON trivially and will conform to the analogous TypeScript interface type.

Note: If you are using Python 2 or older versions of Python 3, you may need to use the older function-based syntax for TypedDict:

from mypy_extensions import TypedDict

Address = TypedDict('Address', {
    'street': str,
    'housenumber': int,
})

Alternatives

There are other ways in Python to represent structures with named properties.

Data classes, available in Python 3.7, have read-write keys. However they cannot be serialized to/from JSON automatically.

from dataclasses import dataclass

@dataclass
class Address:
    street: str
    housenumber: int

my_address = Address(
    street='SW Gemini Dr.',
    housenumber=9450,
)

Named tuples are cheap and have read-only keys. They also cannot be serialized to/from JSON automatically.

from typing import NamedTuple

class Address(NamedTuple):
    street: str
    housenumber: int

my_address = Address(
    street='SW Gemini Dr.',
    housenumber=9450,
)

Simple namespaces, available in Python 3.3, are similar to data classes but are not very well known.

from types import SimpleNamespace

class Address(SimpleNamespace):
    street: str
    housenumber: int

my_address = Address(
    street='SW Gemini Dr.',
    housenumber=9450,
)

attrs is a long-standing third-party library that is similar to data classes but with many more features. attrs is recognized by the mypy typechecker.

import attrs

@attr.s(auto_attribs=True)
class Address:
    street: str
    housenumber: int

my_address = Address(
    street='SW Gemini Dr.',
    housenumber=9450,
)
🌐
GitHub
github.com › Latios96 › py-typescript-generator
GitHub - Latios96/py-typescript-generator · GitHub
Note: Currently, only Python dataclasses are supported, but it's possible to extend this to other sources, like attrs classes or SqlAlchemy models. This project is heavily inspired by the typescript-generator project by Vojtěch Habarta, a TypeScript generator for Java classes.
Starred by 9 users
Forked by 2 users
Languages   Python
🌐
GitHub
github.com › topics › typescript-python
typescript-python · GitHub Topics · GitHub
To associate your repository with the typescript-python topic, visit your repo's landing page and select "manage topics."
🌐
DEV Community
dev.to › themuneebh › i-have-built-an-api-using-typescript-python-and-go-so-you-dont-have-to-b2h
I have built an API using TypeScript, Python, and Go, so you don't have to. - DEV Community
May 2, 2024 - That's it, so which one are you going to use for your next project? ... Generalist turned Go full time a bunch of years ago. ... I would always choose Go as I find the syntax a culmination of best practices from other languages as well. But I do admit it is verbose for some cases. That's why I was excited about the language getting some generics programming. I created github.com/dolanor/rip just to avoid most of this boilerplate in REST API creation.
🌐
GitHub
github.com › topics › typescript
typescript · GitHub Topics · GitHub
TypeScript compiles (or transpiles) ... environment. It can be used to develop JavaScript for both client-side and server-side applications. ... All 281,909 TypeScript 229,696 JavaScript 18,010 Vue 6,502 HTML 4,985 CSS 3,057 Java 1,911 Svelte 1,665 Python 1,545 SCSS 1,279 C# ...
🌐
Reddit
reddit.com › r/typescript › side project for converting python into typescript
r/typescript on Reddit: Side project for converting Python into TypeScript
December 26, 2020 - You want to port a Python library. Lots of use cases for compilers. ... For more information you can check github or ask me. This project still have some sharp edges that I'll need deal with later ; ) https://github.com/YushchenkoAndrew/ts-doodle ... Nice, I wonder if you could somehow use the typescript language server to implement type inference by usage?
🌐
GitHub
github.com › pulumi › pulumi › issues › 6302
Performance difference between Python and Typescript · Issue #6302 · pulumi/pulumi
February 10, 2021 - I ran a benchmark deploying a Helm chart with Pulumi, using two languages: Python and Typescript. It seems that Typescript is quite a bit faster than the Python implementation. I just upped and destroyed a single Helm chart several times...
Author   ppawiggers
🌐
GitHub
github.com › w0rp › python-to-typescript
GitHub - w0rp/python-to-typescript: Python tools for generating TypeScript interfaces from Python types · GitHub
September 9, 2023 - Python tools for generating TypeScript interfaces from Python types - w0rp/python-to-typescript
Starred by 11 users
Forked by 5 users
Languages   Python 96.8% | Shell 3.2%
🌐
Plain English
python.plainenglish.io › typed-python-for-typescript-developers-791145e7171c
Typed Python For TypeScript Developers | by Mattias Naarttijärvi | Python in Plain English
May 5, 2021 - Check out this git repo for exact setup for both TypeScript and typed Python used in this article. ... New Python content every day. Follow to join our 3.5M+ monthly readers. ... Energy Engineer by trade, but Software Developer by heart. Doing my best to save the planet; currently by optimising heat- & energy production at Sigholm Tech.
🌐
Reddit
reddit.com › r/python › is a typescript-like language for python possible and desirable?
r/Python on Reddit: Is a TypeScript-like language for Python possible and desirable?
December 6, 2024 -

While tools like MyPy, Pyright, and Pylance have significantly improved static typing in Python, they don't offer the same level of rigor and performance as fully compiled languages.

Imagine a language that compiles to Python bytecode, providing:

  • Strong static typing: catching errors early and improving code reliability.

  • Performance benefits: through compilation and optimizations.

  • Advanced language features: such as algebraic data types, pattern matching, and better concurrency support.

But what are the trade-offs? Would such a language be compatible with the vast Python ecosystem? Could a compiler achieve the same performance as the CPython interpreter? And would the added complexity outweigh the benefits for many Python developers?

I'm curious to hear your thoughts. Have you ever experimented with statically typed Python dialects or considered the potential benefits and drawbacks of a more rigid type system?

Top answer
1 of 3
7
TypeScript and Python+Mypy are in many ways very similar. But whereas TypeScript is a transpiler in order to add the necessary type annotation syntax to JavaScript, Python has evolved to add the necessary syntax infrastructure in the core language. This isn't necessarily perfect as this imposes hard restrictions on the power of the Python type system. TypeScript has also used the transpiler capabilities to add small runtime helpers to the language, e.g. null-safe navigation operators long before this made it to the core language. Neither TypeScript nor Python+Mypy type annotations improve the speed of the code. The types are only used for type checking. There is however mypyc , a project that compiles Python code to C extensions, using type annotations to provide the necessary typing info. This is not a magic "go faster" button, but should perhaps be understood more as an alternative to Cython, which is a separate but Pyhon-like language for writing C extensions. Python already has algebraic data types: your product types can be represented via tuples, dataclasses, or other classes. Your sum types don't need a runtime representation (ordinary objects suffice), and the type-system level representation is the Union type A | B – same as in TypeScript. Python already has pattern matching. See the match/case statement. If your goal is to compile to Python bytecode, you cannot get concurrency/multithreading benefits. The limiting factor is the Python data model. There is active progress on that matter, e.g. Python 3.13 introduced a "free threading" mode without the GIL. However, C extensions must be updated to be compatible with this mode, so it will take a couple of years until the benefits actually materialize for real-world projects.
2 of 3
1
As a web developer with ~20 years experience I’m think that python has gone too far in trying to be all-things-to-all-people. Python is a great language. It has a low barrier to entry and is incredibly versatile, but the number of sticking plasters trying to make something that’s nearly 40 years old and originally designed as a replacement for BASIC behave like a high-performance object-orientated language is excessive. If you want these features, learn a language which has them baked into their original design. Your knowledge as a developer will skyrocket.
🌐
InfoWorld
infoworld.com › home › artificial intelligence
TypeScript rises to the top on GitHub | InfoWorld
October 28, 2025 - August 2025 marked the first time TypeScript emerged as the most-used language on GitHub, overtaking both JavaScript and Python, said the report. The rise of TypeScript illustrates the shift toward using typed languages, which can make agent-assisted coding more reliable in production, according to GitHub.