Menu
CoddyTech
Course

TypeScript for Rust Developers

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

Rust and TypeScript side by side

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

  1. Run TypeScript

    Rust compiles crates into machine code and uses an explicit main entry point. TypeScript instead emits JavaScript executed by Node, and its types are erased. This course introduces JavaScript variables, arrays, objects and functions without assuming prior…

    Rust
    1
    2fn main() {3    let name = "Ada";4    println!("Hello, {}!", name);5}
    TypeScript
    1const name: string = "Ada";2console.log(`Hello, ${name}!`);3export {};
  2. Numbers and Conversion

    Rust string parsing returns Result, so the caller handles an error or explicitly expects success for a known literal. JavaScript Number instead can yield NaN, and blank text converts to zero. Explicit conversion and validation replace the Rust Result check…

    Rust
    1
    2fn main() {3    let value: i32 = "12".parse().expect("valid integer");4    println!("{}", value + 3);5}
    TypeScript
    1const value: number = Number("12");2console.log(value + 3);3export {};
  3. Arrays and Slice

    Rust slices borrow existing storage; to_vec clones elements into an owned vector. JavaScript slice creates a new outer array. Both exclude the end bound, but JavaScript missing indexed reads return undefined rather than a Rust index panic. Rust get offers an…

    Rust
    1
    2fn main() {3    let values = [1,2,3,4];4    let middle = values[1..values.len()-1].to_vec();5    println!("[{},{}]", middle[0], middle[1]);6}
    TypeScript
    1const values: number[] = [1, 2, 3, 4];2console.log(JSON.stringify(values.slice(1, -1)));3export {};
  4. For-of and Array Values

    Rust for consumes an IntoIterator; iter, iter_mut and into_iter distinguish borrowing and ownership. JavaScript for-of yields values, while for-in enumerates keys rather than consuming a Rust-style iterator. Use entries when you need both index and value.

    Rust
    1
    2fn main() {3    let values = [3,-1,2];4    let mut total = 0;5    for value in values { if value > 0 { total += value; } }6    println!("{}", total);7}
    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

    Rust conditions require bool, so collection emptiness must be tested explicitly. JavaScript treats an empty array as true. The source nonempty check and target truthiness check intentionally differ; translating collection conditions requires a deliberate…

    Rust
    1
    2fn main() {3    let values: Vec<i32> = Vec::new();4    println!("{}", !values.is_empty());5}
    TypeScript
    1const value: unknown = [];2console.log(Boolean(value));3export {};
  6. Annotations and Inference

    Rust distinguishes integer widths and floating-point types and requires explicit numeric conversion for mixed operands here. TypeScript number uses JavaScript floating-point arithmetic. Annotating a count as number does not provide Rust integer overflow or…

    Rust
    1
    2fn main() {3    let price: f64 = 2.5;4    let count: i32 = 4;5    println!("{}", price * f64::from(count));6}
    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 Rust developers

Learn TypeScript from another language

Frequently asked questions

Who is TypeScript for Rust Developers for?

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

How many lessons does TypeScript for Rust Developers have?

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

What does TypeScript for Rust Developers cover?

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

Is TypeScript for Rust 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 Rust Developers for free

Get started