Current date May 18, 2026
Programming

TypeScript 5.x: features that change how you write code

URL copied
Share URL copied
TypeScript 5.x: features that change how you write code
TypeScript 5.x: features that change how you write code

TypeScript continues to evolve at a rapid pace. The 5.x versions brought changes that go beyond performance improvements: they redefine patterns we have been using for years.

`const` Type Parameters

Before you needed `as const` on every call to infer literal tuples. Now you can declare it in the generic:

// Before: inferred as string[]
function head(arr: T[]) {
  return arr[0];
}
head(["a", "b"]); // type: string

// Now: inferred as the exact literal // [!code highlight]
function head(arr: T) {
  return arr[0];
}
head(["a", "b"] as const); // type: "a"
head(["a", "b"]); // type: "a"  ← works without as const // [!code ++]

`satisfies` operator (consolidated)

Introduced in 4.9 but already part of the daily workflow. It allows validating that a value satisfies a type without “widening” it:

type Palette = {
  red: [number, number, number] | string;
  green: [number, number, number] | string;
  blue: [number, number, number] | string;
};

const palette = {
  red: [255, 0, 0],
  green: "#00ff00",
  blue: [0, 0, 255],
} satisfies Palette; // [!code highlight]

// Now TypeScript knows that red is a tuple, not string
palette.red.at(0); // ✓ — before it threw an error

Improvements in `infer` inference

// Extract the return type filtered by constraint
type ReturnIfString = T extends () => infer R extends string
  ? R
  : never;

type A = ReturnIfString "hello">; // "hello"
type B = ReturnIfString number>;  // never

Performance: `–incremental` and `–composite` mode

TS 5.x optimized incremental builds. In large projects the improvement can be up to :

{
  "compilerOptions": {
    "composite": true,
    "incremental": true,
    "tsBuildInfoFile": ".tsbuildinfo",
    "moduleResolution": "bundler"
  }
}

> Tip: combine `composite` with project references (`references`) for monorepos. Each package will compile only what changed.

Quick summary

| Feature | Version | Impact |

| ————————– | ———————— | —————————————- |

| Standard decorators | 5.0 | High — replaces experimental |

| `const` type params | 5.0 | Medium — less `as const` |

| `satisfies` | 4.9 / consolidated in 5.x| High — more expressive typing |

| `infer … extends` | 5.x | Medium — more precise conditional types |

| Improved incremental build | 5.x | High in monorepos |

Share URL copied

Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Active0
AI3
AI & Automation10

Exclusives

Lifestyle

Related Articles

Rust for JavaScript developers: the leap worth taking

If you come from the JS/TS world and Rust intimidates you, this...