TypeScript for Python Developers
Learn the JavaScript runtime and TypeScript contracts from Python. Practice typed flow, functions, collections and class modules, then build a validated order-processing tool.
Python and TypeScript side by side
The same program in Python and in TypeScript, from the lessons of this course.
Run TypeScript
Python annotations are optional metadata for external checkers. TypeScript also erases types, but this course runner checks and compiles TypeScript before Node executes it. Braces and semicolons replace Python indentation-based blocks. Read the supplied typed…
Python1name: str = "Ada"2print(f"Hello, {name}!")TypeScript1const name: string = "Ada";2console.log(`Hello, ${name}!`);Numbers and Conversion
Python int and float conversion raise ValueError for bad numeric strings. JavaScript Number returns NaN instead, and unexpectedly converts blank text to zero. Validate blankness and finiteness explicitly. A TypeScript annotation does not perform conversion.…
Python1print(int("12") + 3)TypeScript1const value: number = Number("12");2console.log(value + 3);Arrays and Slice
Python slicing maps naturally to JavaScript slice, but a negative bracket index does not retrieve the last array element in JavaScript. Use at(-1) or an explicit length-based index. An out-of-range bracket read returns undefined instead of IndexError.…
Python1import json2print(json.dumps([1, 2, 3, 4][1:-1], separators=(",", ":")))TypeScript1const values: number[] = [1, 2, 3, 4];2console.log(JSON.stringify(values.slice(1, -1)));For-of and Array Values
Translate Python for value in values to JavaScript for (const value of values). JavaScript for-in is key enumeration, not Python iterable iteration. There is no built-in range syntax required here: for-of already supplies each element. JavaScript uses braces…
Python1total = 02for value in [3, -1, 2]:3 if value > 0:4 total += value5print(total)TypeScript1let total: number = 0;2for (const value of [3, -1, 2]) { if (value > 0) total += value; }3console.log(total);Truthiness Is Not Emptiness
Python empty lists and dictionaries are falsy, whereas JavaScript empty arrays and objects are truthy. The paired examples intentionally print different booleans. Test collection length explicitly when translating Python if values code. JavaScript conditions…
Python1import json2print(json.dumps(bool([])))TypeScript1const value: unknown = [];2console.log(Boolean(value));Annotations and Inference
Python separates arbitrary-precision int from float. TypeScript number uses JavaScript floating-point arithmetic for both whole and fractional values. BigInt is a separate runtime type outside these exercises; do not assume Python-sized integers are exact as…
Python1price: float = 2.52count = 43print(format(price * count, "g"))TypeScript1const price: number = 2.5;2const count = 4;3console.log(price * count);
Syllabus
12 chapters48 lessons1 project48 challenges96 quiz questionsStart Here
1 lessonRuntime Values
4 lessonsRuntime Collections
4 lessonsRuntime Control Flow
4 lessonsRuntime Edge Cases
4 lessonsTyped Contracts
5 lessonsTyped Flow
5 lessonsTyped Functions
5 lessonsTyped Collections
5 lessonsReliable Modules and Objects
5 lessonsProject: Typed Orders
4 lessonsFinal Challenges
2 lessonsFrequently asked questions
Who is TypeScript for Python Developers for?
For people who already write Python and want to learn TypeScript. Each lesson starts from Python you know and shows how TypeScript does the same thing, so you skip the beginner basics.
Do I need to know TypeScript already?
No. The course starts with your first TypeScript program. You need Python basics: variables, conditions, loops, functions and collections.
How many lessons does TypeScript for Python Developers have?
TypeScript for Python Developers contains 48 interactive lessons you can complete at your own pace.
What does TypeScript for Python Developers cover?
The course is organized into chapters covering: Start Here, Runtime Values, Runtime Collections, Runtime Control Flow, and more.
Is TypeScript for Python Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.