TypeScript 4.8 fixes file watching on Linux, macOS

TypeScript 4.8 fixes file watching on Linux, macOS

Update to Microsoft’s typed JavaScript also introduces improvements to how intersection and union types work and how TypeScript narrows types.

Credit: Dreamstime

TypeScript 4.8, a planned upgrade to Microsoft’s popular strongly typed JavaScript variant, is set to add correctness and consistency improvements and file-watching fixes to the language.

Published as a beta release June 21, TypeScript 4.8 is due for general availability on August 23. With the beta, a series of improvements to consistency and correctness is introduced under strictNullChecks. These changes affect how intersection and union types function and are leveraged in how TypeScript narrows types. 

In one example, unknown is close in spirit to the union type {} | null | undefined because it accepts null, undefined, and any other type. 

TypeScript now recognises this and allows assignments from unknown to {} | null | undefined. Changes in TypeScript 4.8 allow for sensible improvements in control flow and type narrowing, Microsoft said. Generic values also get narrowed.

As for the file-watching fixes, TypeScript has had a longstanding bug where the language has had a hard time with certain file changes in --watch mode and editor scenarios. Frequently, these occur on Unix systems. 

The situation was caused by assumptions regarding how Node.js handles rename events across file systems. File systems used by Linux and MacOS use inodes, and Node.js will attach file watchers to inodes rather than file paths. 

TypeScript tries to use the same watcher objects if it detects a path still exists on disk, so would end up reusing the watcher object instead of installing a new watcher at the original location, and would watch for changes at what might be an irrelevant file. TypeScript 4.8 handles these cases on inode systems properly and installs a new watcher.

Elsewhere in TypeScript 4.8, optimisations have been introduced to speed up scenarios around –-watch and --incremental, along with project references using --build.

Meanwhile, inference from binding patterns has been improved and when running find-all-references in an editor, TypeScript now is smarter in aggregating references. This reduced the amount of time needed to search a widely used identifier by about 20 per cent.

Also, and in a breaking change, unconstrained generics are no longer assignable to {}. In another breaking change, types cannot be imported or exported in JavaScript files.

The TypeScript 4.8 beta can be downloaded via NuGet, or via NPM using the following command:

npm install -D typescript@beta

TypeScript 4.8 follows last month’s release of TypeScript 4.7.

Follow Us

Join the newsletter!


Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Tags TypeScript


EDGE 2023

EDGE is the leading technology conference for business leaders in Australia and New Zealand, built on the foundations of collaboration, education and advancement.


ARN has celebrated gender diversity and recognised female excellence across the Australian tech channel since first launching WIICTA in 2012, acknowledging the achievements of a talented group of female front runners who have become influential figures across the local industry.

ARN Innovation Awards 2023

Innovation Awards is the market-leading awards program for celebrating ecosystem innovation and excellence across the technology sector in Australia.

Show Comments