Skip to content

Stop writing Python in TypeScript.

The whitespace was nice while it lasted. Brace yourself.

Step 1 of 4

Good Python. Dataclasses and isinstance, exactly what you were taught.

shapes.pyPython
@dataclass
class Circle:
    radius: float

@dataclass
class Rect:
    width: float
    height: float

def area(s):
    if isinstance(s, Circle):
        return pi * s.radius ** 2
    return s.width * s.height

You’d recognize it in review.

Five tells that a TypeScript file was written by a Python dev. They’re all habits Python taught you.

  • class UserService { constructor() {} }

    A class with one method and a constructor. That’s just a function returning a typed object.

  • string | null

    Nulls everywhere, narrowed by hand. Optional usually means | undefined here, and the difference bites.

  • const name: string = "katie"

    Annotating what the compiler already knows. Let inference do its job and save the annotations for the boundaries.

  • try { } catch (e) { }

    try/catch wrapped around code that can’t throw. In Python exceptions are control flow. Here they’re for real failures.

  • typeof s === "object" && "radius" in s

    An isinstance-shaped chain of typeof checks. A kind field does this with proof the compiler can read.

Module 01

Unlearning Python.

Module 1 is live. Eleven lessons on the type system. Every exercise runs against the real TypeScript compiler in your browser. Free, no signup. Three more modules are coming. Get those by signing up below.

01Your TypeScript reads like Python
02Stop annotating everything
03Duck typing, formalized
04Unions instead of inheritance
05None, null, undefined: three nothings
06Discriminated unions
07Classes everywhere: the Python tell
08unknown vs any
09Generics without fear
10The pydantic-shaped hole
11async/await: same keywords, different machine

Get each module the day it ships.

The whole course is free. Module 1 is open right now, no signup. New modules go out by email first, so if you want Module 2 the day it ships, this is the list.

Module releases, build notes, and the occasional other project.