TypeScript 5.9: A Step Closer to Modern Javascript

TypeScript 5.9: A Step Closer to Modern Javascript

Welcome back to your newsletter!

TypeScript 5.9 has landed, and while it doesn’t bring big breaking changes, it’s packed with quality-of-life updates.

Here’s what you need to know.

Article content

Const Inference Improvements

In TypeScript 5.8 and earlier, inferring literal types from const returns often required explicit annotations. Not anymore.

Before:

function makeDirection() {
  return { up: "UP", down: "DOWN" }
}

const result = makeDirection()
// type inferred: { up: string; down: string }        

Now in 5.9:

function makeDirection() {
  return { up: "UP", down: "DOWN" } as const
}        

Better Type Narrowing in Control Flow

TypeScript now tracks control flow more precisely. For example, inside switch statements and nested conditionals, the compiler narrows types more effectively:

type Shape = { kind: "circle", radius: number } | { kind: "square", side: number }

function getArea(shape: Shape) {
  switch (shape.kind) {
    case "circle":
      return Math.PI * shape.radius ** 2
    case "square":
      return shape.side * shape.side
  }
}        

In 5.9, TypeScript more confidently infers that shape in each case is narrowed to the correct type, improving code completion and eliminating unnecessary type guards.

Article content

Performance Gets a Boost

Developers working in large monorepos or CI-heavy environments will benefit from the compiler’s performance upgrades.

The project build time is improved by optimising internal caches and reducing the cost of redundant checks. There is no change required to benefit from this – just upgrade and enjoy the speed boost.

In editors like VS Code, you may also notice smoother interactions when hovering over types or using IntelliSense on complex objects or generic-heavy libraries.

New: Experimental 'using' Keyword Support

TypeScript 5.9 introduces experimental support for the using keyword, part of a new JavaScript proposal for explicit resource disposal.

Here’s an early example:

using db = connectToDatabase()
// db is automatically cleaned up when it goes out of scope        

JSDoc Enhancements for Generics

A new @typeParameters JSDoc tag has been added, making documentation of generics more precise:

/**
 * @typeParameters T - The type of input value
 */
function identity<T>(value: T): T {
  return value
}        

This improves developer experience when consuming well-documented libraries or maintaining internal shared utilities.

Article content

Smarter Auto Imports and Type Suggestions

TypeScript 5.9 now ranks auto-import suggestions more accurately based on usage and context. It also improves type suggestion ordering in the editor, helping developers find the right type faster.

This is particularly useful in large projects where multiple similarly named modules exist across the codebase.

No Breaking Changes, Just Better DX

This release does not include major breaking changes. It’s safe to upgrade for most teams, especially if you are already on 5.7 or 5.8.

You can try it with:

npm install typescript@latest        

In Summary

TypeScript 5.9 strengthens the developer experience with smarter type inference, improved narrowing, faster builds, and editor polish. While experimental features like using show a glimpse of what’s next, most of this release is ready for use today.

For engineering teams looking to improve code clarity and performance without a migration headache, TypeScript 5.9 is a strong and safe upgrade.


Is your team hiring?

We work with global businesses across the UK, Germany and the US to help them find top talent quickly.

Reach out to us for a recruitment strategy session

🔥 Hot Jobs by develop 🔥

Senior Software Engineer

Financial Analyst

ServiceNow Test Lead

Dotnet Developer

See More

😎 Our Social Stories 😎

130+ people shared where they see the biggest opportunity in AI jobs, here`s what they said

develop turned 13 last week!


Are you following us?

Click here to be the first to get our updates!

To view or add a comment, sign in

Others also viewed

Explore topics