Web development

What's new in TypeScript 5: what you need to know

David Morales VegaOctober 20, 20258 min read

Originally published on Bemorex Learn, our learning platform. · Leer en español

Standard decorators

TypeScript 5 introduces support for ECMAScript standard decorators (Stage 3). These are different from the experimental decorators we used before and follow the official specification.

Const type parameters

const type parameters allow inferring more precise types from literal values, eliminating the need for as const in many cases.

Performance improvements

TypeScript 5 includes significant performance improvements: faster compilations, lower memory usage, and better support for large projects with project references.

Advanced use of satisfies

The satisfies operator introduced in TypeScript 4.9 is now complemented with new capabilities that allow validating types without losing literal type inference.

Migration guide

Migrating to TypeScript 5 is relatively straightforward. Most breaking changes are minor and ecosystem tools already have full support.

Code examples

TypeScript

// Standard decorators in TypeScript 5
function log(
  target: unknown,
  context: ClassMethodDecoratorContext
) {
  const methodName = String(context.name);
  return function (this: unknown, ...args: unknown[]) {
    console.log(`Calling ${methodName}`);
    return (target as Function).apply(this, args);
  };
}

class UserService {
  @log
  getUser(id: string) {
    return { id, name: 'Carlos' };
  }
}

Keep reading

Want to build something like this?

Tell us what you need: we look at it together and propose a way forward in writing, in English or Spanish.

[email protected]