You can try this https://github.com/amol-/dukpy which is a combo of Python and C and offers limited TypeScript compilation capabilities.

In general you might be better off using a native TypeScript compiler and call it from Python instead

Answer from Philippe Ombredanne on Stack Exchange
🌐
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 24 users
Forked by 3 users
Languages   TypeScript 91.3% | JavaScript 8.7%
🌐
PyPI
pypi.org › project › dukpy
dukpy · PyPI
DukPy is a simple javascript interpreter for Python built on top of duktape engine without any external dependency. It comes with a bunch of common transpilers built-in for convenience: CoffeeScript · BabelJS · TypeScript · JSX · LESS · Using the coffeescript compiler is as easy as running: >>> import dukpy >>> dukpy.coffee_compile(''' ...
      » pip install dukpy
    
Published   Nov 07, 2024
Version   0.5.0
🌐
Marcjschmidt
marcjschmidt.de › pybridge
PyBridge - TypeScript to Python Bridge // Blog // Marc J. Schmidt
By utilizing Deepkit's Type-Compiler, PyBridge ensures that the TypeScript types defined for Python functions are not only used for compile-time checks but also for runtime validation and serialization.
🌐
Reddit
reddit.com › r/typescript › how to create a python api for a project based on typescript ?
r/typescript on Reddit: How to create a Python API for a project based on Typescript ?
March 13, 2022 -

Hey TS community on Reddit

I am looking for some help / guidance & would be grateful for any helpful advice

So there's a project that i came across that is written in mostly typescript. However, i want to use a flask/python based front-end for it, so i need to know how can i make an API / package in Python that can call/execute typescript code from the project ?

I am not sure if my technical vocabulary is entirely correct, but basically i am looking to integrate a Typescript project in a Python front-end; by making calls to Typescript commands / calls from Python.

Would appreciate any and all help in this regard !

EDIT : I am not very proficient in Javascript or Typescript

🌐
PyPI
pypi.org › project › ts2python
ts2python · PyPI
Software Development :: Compilers ... for Typescript-Interfaces. Transpiles TypeScript-Interface-definitions to Python TypedDicts, plus support for run-time type-checking of JSON-data....
      » pip install ts2python
    
Published   Oct 30, 2025
Version   0.8.2
🌐
CodeConvert AI
codeconvert.ai › typescript-to-python-converter
TypeScript to Python Converter
Type or paste your TypeScript code in the input box. Click the convert button. The resulting Python code from the conversion will be displayed in the output box.
🌐
Netguru
netguru.com › home page › blog › typescript vs python: which programming language fits your needs?
TypeScript vs Python: Which Programming Language Fits Your Needs?
July 1, 2025 - TypeScript requires developers to invest time in type definitions and managing dependencies through the typescript compiler, but this upfront investment pays dividends in developer productivity and code easier maintenance. Python’s dynamic typing allows for faster prototyping and experimentation, making it excellent for coding challenges and research projects.
Find elsewhere
🌐
Slant
slant.co › versus › 110 › 378 › ~python_vs_typescript
Slant - Python vs TypeScript detailed comparison as of 2025
In order to avoid this, you have to declare type signatures for every variable or parameter or set the flag --noImplicityAny when running the compiler. Even in cases were there is no ambiguity, you still have to use "this.fieldName" instead of just "fieldName". Typescript compiler does not remove dead code from generated file(s), you have to use external tools to remove unused code after compilation.
🌐
Reddit
reddit.com › r/compilers › python v. typescript; which is better to prototype/write a compiler in?
r/Compilers on Reddit: Python v. TypeScript; which is better to prototype/write a compiler in?
October 28, 2024 -

Of course, people have reservations against using either. However, my question is only regarding which is better of the two.

Would the answer be different if,

  1. The compiler targets -> ARM v. NASM

  2. The compiler targets -> LLVM IR

  3. C (like how, for example Nim, does things)

  4. I don't use my own parser/lexer, and use libraries

Top answer
1 of 11
5
I much prefer Python. To me, TypeScript doesn't really address the general problems I have with JavaScript - which come down to how ergonomic it is for programming (custom key types in data structures - without devolving to strings, pattern matching, a less obtuse encoding of ADTs). Nowadays, with Python's match construct, @dataclass annotations, type annotations, etc. you can write pretty concise compiler code in fairly ergonomic ways. Hacked this together in a vague effort to support my comment. Of course, I'd try to find LLVM bindings in reality.
2 of 11
3
I have proto-typed the compiler for Cwerg in python. My plan is to re-implement all the components in C++ as soon as they stabilize. (The backend has already been re-implemented.) I really like the fast turnaround times that Python gives me. I do use type annotations almost everywhere as they improve the IDE support dramatically. But I wish python were a little bit faster. My understanding is that typescript needs to transpile to JS first, so there is a higher startup cost but then it runs faster because of the JIT. So with Typescript you do not necessarily have to re-implement in the compiler in a higher performing language. My compiler frontend currently emits a textual IR which the backend converts to object code. I think your bullets 1-3 do not make much of a difference. Cwerg uses a custom recursive descent parser with pratt parsing for expressions. I have used flex/bison way back then and I think that parsing libs are not that useful, especially if you come up with your own syntax.
🌐
Reddit
reddit.com › r/python › why doesn't python have a typescript?
r/Python on Reddit: Why doesn't Python have a TypeScript?
August 17, 2016 -

And no, the built in "type hints" don't count.

It would be great to use a statically compiled language in the world of Python.

TypeScript's approach would be perfect. Build type definitions for all your dependencies. Support strict mode or not, allowing you to buck the system if needed.

Do Python debuggers support source maps? Probably not, considering there are no transpilers (that I'm aware of).

🌐
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.
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
23

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,
)
🌐
LogRocket
blog.logrocket.com › home › why is typescript surpassing python?
Why is TypeScript surpassing Python? - LogRocket Blog
June 20, 2024 - You can see that future errors are already being prevented even before the code is compiled. That is what makes TypeScript so powerful. Because Python is dynamically typed, variable types are only determined at runtime, causing it to consume chunks of memory during execution.
🌐
Programiz
programiz.com › typescript › online-compiler
Online Typescript Compiler (Editor) - Programiz
Write and run your Typescript code using our online compiler. Enjoy additional features like code sharing, dark mode, and support for multiple programming languages.
🌐
AWS
aws.amazon.com › blogs › opensource › generate-python-java-dotnet-software-libraries-from-typescript-source
Generate Python, Java, and .NET software libraries from a TypeScript source | AWS Open Source Blog
March 22, 2021 - These restrictions and conventions are documented on GitHub and the compiler generates helpful error messages, along with instructions to resolve any violations. To summarize, the restrictions over vanilla TypeScript include:
🌐
Loopwerk
loopwerk.io › articles › 2025 › type-systems
Loopwerk: A tale of three type systems: Python, TypeScript, and Swift
This is the runtime safety I was so desperately missing from TypeScript. Saga’s Swift code is also complex, but it’s a manageable complexity. The compiler is a true partner. It holds your hand, guides you through refactoring, and guarantees that if it compiles, it’s type-safe. The Python version was a headache of ambiguity; the Swift version, while challenging, is a puzzle with a guaranteed solution.
🌐
GitHub
github.com › marcj › pybridge
GitHub - marcj/pybridge: TypeScript library to access python functions in NodeJS, type-safe and easy to use.
Supports all TypeScript types (including generics) Supports generator functions in Python (streaming with RxJS)
Starred by 78 users
Forked by 10 users
Languages   TypeScript 98.1% | Python 1.9%
🌐
JetBrains
jetbrains.com › help › pycharm › compiling-typescript-to-javascript.html
Compiling TypeScript into JavaScript | PyCharm Documentation
PyCharm doesn't use just the nearest tsconfig.*.json (from the list of files recognized as Typescript config file type). PyCharm uses the nearest tsconfig.*.json in which a particular file is somehow specified – either explicitly in the files field or through patterns in the include and exclude fields. You can invoke compilation manually or have PyCharm compile your code automatically every time the code is changed.