Menu
CoddyTech
Course

TypeScript for Dart Developers

Learn TypeScript and the JavaScript runtime from Dart: values, control flow, callbacks, typed collections, validation and object modules. Build a connected order-processing project and port two source programs.

Dart and TypeScript side by side

The same program in Dart and in TypeScript, from the lessons of this course.

  1. Run TypeScript

    Dart runs typed programs with runtime type checks. TypeScript compiles to JavaScript and erases annotations. Start with familiar variables and interpolation, then learn let/const, object literals and JavaScript execution before advanced types.

    Dart
    1void main() {2String name="Ada";3print("Hello, $name!");4}
    TypeScript
    1const name: string = "Ada";2console.log(`Hello, ${name}!`);3export {};
  2. Numbers and Conversion

    Dart int.parse throws FormatException for malformed input, and tryParse returns null. JavaScript Number can return NaN and converts blank strings to zero. Validate blankness and finiteness before adding; a TypeScript annotation does not convert text.

    Dart
    1void main() {2print(int.parse("12")+3);3}
    TypeScript
    1const value: number = Number("12");2console.log(value + 3);3export {};
  3. Arrays and Slice

    Dart sublist and JavaScript slice exclude the end index, but JavaScript bracket access outside the array returns undefined instead of throwing RangeError. JavaScript negative bracket indexes are property lookups, not last-element access.

    Dart
    1import 'dart:convert';2void main() {3print(jsonEncode([1,2,3,4].sublist(1,3)));4}
    TypeScript
    1const values: number[] = [1, 2, 3, 4];2console.log(JSON.stringify(values.slice(1, -1)));3export {};
  4. For-of and Array Values

    Dart for-in iterates list values. The JavaScript equivalent is for-of, while for-in enumerates property keys. Keep explicit let or const declarations in the loop and use braces for blocks.

    Dart
    1void main() {2var total=0;3for(final value in [3,-1,2]) {if(value>0) total+=value;}4print(total);5}
    TypeScript
    1let total: number = 0;2for (const value of [3, -1, 2]) { if (value > 0) total += value; }3console.log(total);4export {};
  5. Truthiness Is Not Emptiness

    Dart conditions require bool; you must test isNotEmpty or another explicit predicate. JavaScript permits truthiness and treats empty arrays and objects as true. The source checks nonemptiness while the target example deliberately checks array truthiness.

    Dart
    1void main() {2final values=<int>[];3print(values.isNotEmpty);4}
    TypeScript
    1const value: unknown = [];2console.log(Boolean(value));3export {};
  6. Annotations and Inference

    Dart distinguishes int, double and their num supertype. TypeScript number is the JavaScript floating-point runtime category for ordinary whole and fractional values. Inference can identify local types, but annotations do not convert values.

    Dart
    1void main() {2double price=2.5;3int count=4;4print((price*count).toInt());5}
    TypeScript
    1const price: number = 2.5;2const count = 4;3console.log(price * count);4export {};

Syllabus

12 chapters48 lessons1 project48 challenges96 quiz questions

Start Here

1 lesson

Final Challenges

2 lessons

More courses for Dart developers

Learn TypeScript from another language

Frequently asked questions

Who is TypeScript for Dart Developers for?

For people who already write Dart and want to learn TypeScript. Each lesson starts from Dart 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 Dart basics: variables, conditions, loops, functions and collections.

How many lessons does TypeScript for Dart Developers have?

TypeScript for Dart Developers contains 48 interactive lessons you can complete at your own pace.

What does TypeScript for Dart Developers cover?

The course is organized into chapters covering: Start Here, Runtime Values, Runtime Collections, Runtime Control Flow, and more.

Is TypeScript for Dart Developers free?

Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.

Coddy programming languages illustration

Start TypeScript for Dart Developers for free

Get started