Skip to content
All posts
News3 min read

TypeScript 5.8 Major Speed Up

DebuggerMe TeamDebuggerMe TeamJuly 8, 2026
A laptop screen displaying clean lines of computer programming code
Photo by Unsplash
On this page

The TypeScript team has released version 5.8. The release focuses on improving compilation performance and refining type-checking rules.

For large codebases, this update reduces the time spent waiting for editor diagnostics.

Optimized Return Type Checking

TypeScript 5.8 optimizes how the compiler checks return types in functions. In previous versions, checking complex union returns required a large amount of memory.

The new compiler uses a more efficient lookup algorithm.

This speeds up type-checking on projects that make heavy use of generics and conditional types. For example, when resolving heavily nested ternary types inside generic hooks, editor response speeds have improved by up to 20%:

typescript
// Example of a complex return type checker optimized in 5.8
type RouteResult<T> = T extends { slug: string } 
  ? { data: T; active: boolean } 
  : { error: string };

function resolveRoute<T>(input: T): RouteResult<T> {
  if (input && typeof input === 'object' && 'slug' in input) {
    return { data: input, active: true } as any;
  }
  return { error: "Invalid route" } as any;
}

Faster Incremental Builds

Incremental build compilation has been improved. The compiler is now smarter about detecting which files need to be rechecked when a change occurs.

This reduces subsequent build times during local development.

It helps maintain a fast feedback loop when modifying core type definitions.

Preservation of Type Annotations

TypeScript 5.8 introduces a flag to preserve type annotations in the generated JavaScript. This is useful for compilers and bundlers that perform separate type checks.

Specifically, the new --erasableSyntaxOnly flag ensures that only standard type annotations (which can be easily stripped out) are used.

It disables runtime-impacting TypeScript features like enums, namespaces, and parameter properties:

json
// tsconfig.json example
{
  "compilerOptions": {
    "module": "NodeNext",
    "target": "ES2022",
    "erasableSyntaxOnly": true,
    "noEmit": true
  }
}

This prevents accidental leaks of TypeScript-specific compiler output in bundlers like esbuild or swc, leading to faster type-erasure compiles.

Migration Notes

Turning on erasableSyntaxOnly is not a drop-in change for most existing codebases. If your project uses TypeScript enum, namespace, or constructor parameter properties (constructor(private foo: string)), the compiler will now flag them as errors rather than silently allowing them.

The fix is usually mechanical:

  • Replace enum with a const object plus a derived union type: const Status = { Active: 'active', Done: 'done' } as const; then type Status = typeof Status[keyof typeof Status];
  • Replace parameter properties with explicit field declarations and manual assignment in the constructor body.
  • Namespaces used purely for organizing types can become regular ES modules with named exports.

None of these changes affect runtime behavior. They exist because bundlers like esbuild and swc transpile TypeScript file-by-file without full type information, and features like enums and namespaces generate actual runtime code that a naive per-file transpile can get wrong. Turning the flag on early, even before you need the build speed, catches these patterns before they spread further through a codebase.

DebuggerMe Team

Written by

DebuggerMe Team

The DebuggerMe team builds developer tools, writes technical content, and helps teams ship better software.

Share this post

Back to all posts

Related Articles

All articles →