DEV Community

ANKUSH CHOUDHARY JOHAL
ANKUSH CHOUDHARY JOHAL

Posted on • Originally published at johal.in

The Ultimate tutorial Guide for Rust 1.85 and TypeScript 5.5

The Ultimate Tutorial Guide for Rust 1.85 and TypeScript 5.5

Rust 1.85 and TypeScript 5.5 represent two of the most significant recent releases in systems and web development, respectively. This guide walks you through every feature, setup step, and integration technique you need to master both tools and build high-performance, type-safe applications.

Prerequisites

Before starting, ensure you have the following installed:

  • Rust 1.85 (install via rustup update stable after installing rustup)
  • Node.js v20 or later (for TypeScript 5.5)
  • npm or yarn package manager
  • wasm-pack (for Rust-to-WebAssembly integration: cargo install wasm-pack)

Part 1: What's New in Rust 1.85

Rust 1.85, released in May 2025, stabilizes several critical features for systems development:

  • Full stable support for Generic Associated Types (GATs), enabling more expressive trait definitions
  • 20% faster incremental compilation for projects with 100k+ lines of code
  • Stabilized std::sync::LazyLock for thread-safe lazy initialization
  • Improved error messages for borrow checker violations, with inline suggestions for fixes
  • New target support for RISC-V 64-bit embedded devices

Example: Using GATs in Rust 1.85

// Define a trait with a generic associated type
trait Container {
    type Item<T>;
    fn get<T>(&self, index: usize) -> Option<Self::Item<T>>;
}

struct VecContainer;
impl Container for VecContainer {
    type Item<T> = Vec<T>;
    fn get<T>(&self, index: usize) -> Option<Vec<T>> {
        // Stub implementation
        None
    }
}
Enter fullscreen mode Exit fullscreen mode

Part 2: What's New in TypeScript 5.5

TypeScript 5.5, released in June 2024, brings major improvements to type safety and developer experience:

  • Syntax checking for regular expressions, catching invalid regex patterns at compile time
  • Improved narrowing for Array.prototype.filter with strict null checks enabled
  • Optional chaining support for indexed access types (e.g., obj?.[key] type narrowing)
  • New --target es2024 option for compiling to modern JavaScript
  • Enhanced JSX automatic runtime support for React 19+ and SolidJS

Example: Regex Syntax Checking in TypeScript 5.5

// This will throw a compile-time error in TS 5.5
const invalidRegex = /[a-z/; // Missing closing bracket

// Valid regex works as expected
const validRegex = /[a-z]+/;
const result = validRegex.test("hello"); // Type: boolean
Enter fullscreen mode Exit fullscreen mode

Part 3: Integrating Rust 1.85 and TypeScript 5.5

Rust and TypeScript integrate seamlessly via WebAssembly (Wasm), allowing you to use Rust's performance for compute-heavy tasks and TypeScript's ecosystem for frontend/backend logic.

Step 1: Create a Rust Wasm Project

cargo new --lib rust-ts-demo
cd rust-ts-demo
# Add wasm-bindgen dependency to Cargo.toml
# [dependencies]
# wasm-bindgen = "0.2"
Enter fullscreen mode Exit fullscreen mode

Step 2: Compile to Wasm and Generate TypeScript Bindings

wasm-pack build --target web
# This generates a pkg/ directory with JavaScript and TypeScript bindings
Enter fullscreen mode Exit fullscreen mode

Step 3: Use Rust Wasm in TypeScript

import { greet } from "./pkg/rust_ts_demo";

greet("World"); // Calls Rust's greet function from TypeScript
Enter fullscreen mode Exit fullscreen mode

Part 4: Best Practices

  • Use Rust's Result type for error handling, and map errors to TypeScript-friendly types via Wasm bindings
  • Enable strict mode in TypeScript 5.5 ("strict": true in tsconfig.json) to leverage full type safety
  • Run cargo clippy and tsc --noEmit in CI pipelines to catch issues early
  • Minimize Wasm binary size with wasm-opt for faster page loads

Part 5: Hands-On Project: URL Shortener

Build a full-stack URL shortener with a Rust 1.85 Actix-web backend and TypeScript 5.5 React frontend:

  1. Create a Rust backend with Actix-web that generates short codes and stores mappings in Redis
  2. Compile the backend's core logic to Wasm for edge deployment (optional)
  3. Build a React frontend with TypeScript 5.5 that calls the Rust backend via REST APIs
  4. Add type-safe API bindings between Rust and TypeScript using OpenAPI

Conclusion

Rust 1.85 and TypeScript 5.5 are powerful tools on their own, but together they enable developers to build fast, reliable, and type-safe applications across the stack. Use this guide to get started, and refer to the official documentation for deeper dives into each tool's capabilities.

Resources

Top comments (0)