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.

Answer from hoefling on Stack Overflow
🌐
Medium
medium.com › analytics-vidhya › typescript-for-python-developers-a16e50a5acb2
TypeScript for Python Developers. A quick introduction to TypeScript for… | by Anton De Meester | Analytics Vidhya | Medium
August 28, 2020 - This article will provide a brief but dense overview how TypeScript works, and how you can get started easily. It contains the basic syntax, loops, types, shorthands are more. TypeScript is a superset of Javascript.
🌐
KDnuggets
kdnuggets.com › a-gentle-introduction-to-typescript-for-python-programmers
A Gentle Introduction to TypeScript for Python Programmers - KDnuggets
October 6, 2025 - These utility types ship with TypeScript and solve common patterns. If you need a type that's like User but with optional fields for updates, you can use Partial<User>. And if you need to ensure no modifications after creation, use Readonly<User>. Python developers love try/except blocks, but they can get verbose.
Discussions

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
arguments on why the team should use typescript instead of python?
what's in it for them? More on reddit.com
🌐 r/typescript
46
31
October 30, 2022
python developer on a typescript project
🌐 r/ProgrammerHumor
38
398
November 3, 2022
Python dev looking to learn typescript
I'm guessing you know but I'll say it anyway so that we are on the same page as to why I'm recommending it. Typescript is javascript but with an extra layer that allows your IDE to find errors in code. Typescript doesn't exist in production because it gets transpiled to javascript (essentially jus strip all the typeing and return pure JS) which is then executed in a javascript runtime like node or the browser. It's basically type hinting in Python on steroids. Having said that, there are quite a few resources for javascript for pythonistas, https://github.com/PacktPublishing/Hands-on-JavaScript-for-Python-Developers as an example. You should probably start by learning from something like that and then when you feel comfortable with the basic syntax follow a typescript tutorial to see how typescript is used. But typescript can also be used in stages. A lot of the time typescript is just used for basic typing, but you can do some really insane (both impressive and crazy) typescript statements. May I ask what you're trying to learn typescript for? More on reddit.com
🌐 r/typescript
9
4
March 17, 2025
🌐
Reddit
reddit.com › r/typescript › python dev looking to learn typescript
r/typescript on Reddit: Python dev looking to learn typescript
March 17, 2025 -

Hey there, I'm looking to learn typescript. I´m decent with python and coding concepts in general, so I'm looking for resources that allow me to leverage that (e.g. X in typescript is comparable to Y in python). Can you recommend me some books, articles or videos/youtube channels?

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,
)
🌐
DEV Community
dev.to › andrewbaisden › what-i-realised-after-learning-python-typescript-and-kotlin-44nf
What I realised after learning Python, TypeScript and Kotlin - DEV Community
September 22, 2020 - One pretty big difference between the 3 is that Python uses snack casing for variables such as first_name whereas TypeScript and Kotlin use camel case like firstName. Lastly import statements follow a familiar pattern across all 3 languages. I used to believe that learning too many programming languages would lead to yourself becoming confused as you have to remember all of these different syntax and you could find yourself in a scenario where you are writing Kotlin in JavaScript for example which I'm sure has happened to some developers at least once with multiple languages.
🌐
GitHub
gist.github.com › nedimcanulusoy › 7a92991b6decc243f2240876b14b694a
Python to TypeScript Cheatsheet · GitHub
Classes: Python uses a more traditional ... prototypal inheritance model. However, TypeScript does have a class syntax that provides a more familiar syntax for Java/C++/Python programmers....
Find elsewhere
🌐
Medium
medium.com › @Pilot-EPD-Blog › typescript-for-pythonistas-f90bbb297f0a
TypeScript for Pythonistas. Authored by Allison Kaptur | by Pilot EPD | Medium
December 14, 2021 - For coders familiar with Python, you can get started with a single sentence: think of a type as a Python class. That class might be a user-defined class that you wrote yourself, or a builtin class like str or int. A function that takes an instance of class A should be annotated with the type signature A. So getting started with type annotations didn’t feel too hard. [1] By contrast, TypeScript types weren’t as intuitive.
🌐
Barnes & Noble
barnesandnoble.com › w › typescript-for-python-developers-baldurs-l › 1147529623
TypeScript for Python Developers: Bridging Syntax and Practices by Baldurs L. | eBook | Barnes & Noble®
June 3, 2025 - Python developers will discover how their familiar concepts translate into TypeScript's powerful type system, providing the perfect foundation for building robust web applications with the safety and predictability they've come to expect.
🌐
YouTube
youtube.com › watch
An Introduction to Typescript for Python Programmers - YouTube
➡️ Try Lokalise today: https://bit.ly/arjancodes.TypeScript and Python are both widely used, versatile, and powerful – but actually they couldn’t be more dif...
Published   February 28, 2025
🌐
Medium
medium.com › @frazghuman › key-differences-and-similarities-between-typescript-and-python-basics-98a3f93ccbf7
From TypeScript to Python: A Beginner’s Guide to Language Basics | by Ahmed fraz ud din | Medium
June 21, 2023 - Python and TypeScript share similarities in syntax and programming concepts, but Python’s dynamic typing and whitespace-based block structure set it apart.
🌐
TypeScript
typescriptlang.org › docs › handbook › typescript-from-scratch.html
TypeScript: Documentation - TypeScript for the New Programmer
TypeScript shares syntax and runtime behavior with JavaScript, so anything you learn about JavaScript is helping you learn TypeScript at the same time. There are many, many resources available for programmers to learn JavaScript; you should not ignore these resources if you’re writing TypeScript.
🌐
LogRocket
blog.logrocket.com › home › why is typescript surpassing python?
Why is TypeScript surpassing Python? - LogRocket Blog
June 20, 2024 - Because TypeScript can be used on both sides of a web application, it becomes more convenient to stick to this language and keep the codebase cohesive rather than having to master an entirely different server-side language in order achieve the same functionality. I do not intend to discredit Python as a programming language.
🌐
Reddit
reddit.com › r/typescript › arguments on why the team should use typescript instead of python?
r/typescript on Reddit: arguments on why the team should use typescript instead of python?
October 30, 2022 -

Hi everyone, I have +/- 4 years of experience with typescript, and recently I've had to work in AWS with python code written by people who are not with the team anymore and who weren't programmers by heart. At first, I was excited to focus on python because it's the fastest and cheapest runtime to use in what we do. I have since become the main developer of the team and constantly push for doing better. However, I have been unable to translate the same high-quality standards that I set for myself to python. I feel like the python ecosystem leaves a lot to be desired (package management, linting configuration, automated testing, strict typing, etc). It's in there, but not nearly as good as in the TS/JS/npm ecosystem.

I personally feel like typescript (and npm) could give us a lot of guardrails to help us help ourselves long term to massively improve our code quality.

I'm a bit nervous (because I really hope we can switch to typescript for future projects) and I'm looking for arguments to make during my pitch. Does anyone have any ideas?

p.s. the speed and cost arguments for python are irrelevant according to my manager

🌐
Slant
slant.co › versus › 110 › 378 › ~python_vs_typescript
Slant - Python vs TypeScript detailed comparison as of 2025
When comparing Python vs TypeScript, the Slant community recommends Python for most people. In the question "What is the best programming language to learn first?" Python is ranked 1st while TypeScript is ranked 6th
🌐
StackShare
stackshare.io › stackups › python-vs-typescript
Python vs TypeScript | What are the differences? | StackShare
Python is most praised for its elegant syntax and readable code, if you are just beginning your programming career python suits you best. TypeScript - TypeScript is a language for application-scale JavaScript development.
🌐
CodeConvert AI
codeconvert.ai › typescript-to-python-converter
Free TypeScript to Python Converter — AI Code Translation | CodeConvert AI
Instantly convert TypeScript to Python code with AI. Free, fast, and accurate code translation — 60+ languages supported, no signup required.
🌐
Reddit
reddit.com › r/programmerhumor › python developer on a typescript project
r/ProgrammerHumor on Reddit: python developer on a typescript project
November 3, 2022 - Partial typing has been stable for a while though and there's no excuse not to use it. ... Yep. You wanted types and just threw your hands up at the first error. ... My company uses python and I have to say, please type hint everything. ... I absolutely did this when I transitioned from Javascript node.js to typescript node.js..