TypeScript for Java Developers
Learn JavaScript runtime semantics and TypeScript structural contracts from Java. Practice flow, functions, collections and class modules, then build a validated order-processing tool.
Java and TypeScript side by side
The same program in Java and in TypeScript, from the lessons of this course.
Run TypeScript
Java starts a main method inside a class and runs JVM bytecode. TypeScript modules can run top-level statements and compile to JavaScript for Node. Type annotations disappear; there is no JavaScript prerequisite for this course. The locked main handles JSON…
Java1import java.util.*;2import java.util.function.*;3public class Main {4 5public static void main(String[] args) {6String name = "Ada";7System.out.println("Hello, " + name + "!");8}9}TypeScript1const name: string = "Ada";2console.log(`Hello, ${name}!`);Numbers and Conversion
Java Integer.parseInt throws on malformed integer text. JavaScript Number accepts decimal and exponent notation, returns NaN for invalid numeric text and converts blank strings to zero. Check blankness and Number.isFinite explicitly; annotations do not…
Java1import java.util.*;2import java.util.function.*;3public class Main {4 5public static void main(String[] args) {6System.out.println(Integer.parseInt("12") + 3);7}8}TypeScript1const value: number = Number("12");2console.log(value + 3);Arrays and Slice
Java arrays have fixed length and out-of-range access throws. JavaScript arrays resize and an absent indexed read returns undefined. Slice returns a new range with an exclusive end and permits negative offsets. Splice mutates, despite its similar name.…
Java1import java.util.*;2import java.util.function.*;3public class Main {4 5public static void main(String[] args) {6int[] values = {1, 2, 3, 4};7System.out.println(Arrays.toString(Arrays.copyOfRange(values, 1, values.length - 1)));8}9}TypeScript1const values: number[] = [1, 2, 3, 4];2console.log(JSON.stringify(values.slice(1, -1)));For-of and Array Values
Java enhanced-for uses a colon; TypeScript for-of uses the word of. JavaScript for-in enumerates property keys and is not enhanced-for. Let and const are block scoped, so declarations inside a loop body remain local to that block. JavaScript uses braces for…
Java1import java.util.*;2import java.util.function.*;3public class Main {4 5public static void main(String[] args) {6int total = 0;7for (int value : new int[]{3, -1, 2}) { if (value > 0) total += value; }8System.out.println(total);9}10}TypeScript1let total: number = 0;2for (const value of [3, -1, 2]) { if (value > 0) total += value; }3console.log(total);Truthiness Is Not Emptiness
Java does not allow an array or list as an if condition. You explicitly ask whether it is empty. JavaScript allows objects in conditions and all arrays are truthy, including empty ones. This pair intentionally prints false in Java and true in TypeScript.…
Java1import java.util.*;2import java.util.function.*;3public class Main {4 5public static void main(String[] args) {6List<Integer> values = List.of();7System.out.println(!values.isEmpty());8}9}TypeScript1const value: unknown = [];2console.log(Boolean(value));Annotations and Inference
Java has separate int, long, float and double types. TypeScript number uses JavaScript floating-point arithmetic for whole and fractional values; an annotation does not introduce integer overflow or integer division. Exact large integer work needs a separate…
Java1import java.util.*;2import java.util.function.*;3public class Main {4 5public static void main(String[] args) {6double price = 2.5;7int count = 4;8System.out.println(price * count);9}10}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 Java Developers for?
For people who already write Java and want to learn TypeScript. Each lesson starts from Java 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 Java basics: variables, conditions, loops, functions and collections.
How many lessons does TypeScript for Java Developers have?
TypeScript for Java Developers contains 48 interactive lessons you can complete at your own pace.
What does TypeScript for Java Developers cover?
The course is organized into chapters covering: Start Here, Runtime Values, Runtime Collections, Runtime Control Flow, and more.
Is TypeScript for Java Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.