TypeScript 5.5 Released: What's New in the Latest Version
On June 14, 2024, the Microsoft team officially released TypeScript 5.5 — one of the most significant versions of the popular static type checker for JavaScript. The new update brings developers not only bug fixes but also a number of powerful features that simplify writing code and improve performance. Let's look at the main innovations.
Isolated Declarations
The most anticipated new feature in TypeScript 5.5 is experimental support for the Isolated Declarations mode. Now the compiler can generate declaration files (.d.ts) for each module independently, without needing to load the entire project. This is especially useful for large monorepos and builds where speeding up the compiler becomes critical. The mode can be enabled via the --isolatedDeclarations flag in tsconfig.json.
- Faster builds: isolated type compilation allows parallelizing the process and reducing wait times.
- Convenience for libraries: package authors can now generate up-to-date types faster.
- Backward compatibility: the new mode does not break existing code and can be adopted gradually.
Memory Leak Detection in Closures
TypeScript 5.5 can now warn about potential memory leaks related to closures. The compiler analyzes whether a closure is holding unnecessary references to large objects or DOM elements. For example:
function setupHandler() { const largeData = new Array(1000000).fill('x'); document.getElementById('btn')?.addEventListener('click', () => { console.log('clicked'); // Previously the compiler did not warn that largeData remains in memory });}Now TypeScript will issue a warning if it detects that a closure captures variables that are not used inside it but remain in memory due to being bound to a handler. This helps write more efficient code without manual profiling.
Improved Type Inference for Arrays and Destructuring
The type inference mechanism has been significantly improved in the new version. TypeScript 5.5 now determines types more accurately in array and tuple destructuring. For example, when working with an API that returns tuples, the compiler now correctly recognizes each element:
function fetchUser() { return [1, 'Alice'] as const;}const [id, name] = fetchUser(); // id: number, name: string (previously was union)This eliminates the need for extra manual annotations and makes the code cleaner.
Automatic Type Inference from JSDoc
When using allowJs and checking JavaScript files, TypeScript 5.5 can now automatically infer types from JSDoc comments even in complex cases — for example, for callbacks with multiple parameters. This is especially relevant for projects that are gradually migrating from JS to TS.
Other Improvements and Fixes
- Speed optimization: up to 15% faster compilation for large projects due to caching intermediate results.
- New flags:
--noUncheckedSideEffectImportsprohibits imports without side effects if they are not explicitly used. - Bug fixes: over 80 errors fixed, related