TypeScript 4.8 fixes file monitoring on Linux, macOS


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

Released as a beta on June 21, TypeScript 4.8 is expected to be available on August 23. With the beta, a series of consistency and accuracy improvements are introduced under strictNullChecks. These changes affect how intersection and union types work and are leveraged in how TypeScript restricts types. In one example, unknown is close in spirit to the union type {} | null | undefined because he accepts null, undefined, and any other type. TypeScript now recognizes it and allows assignments from unknown at {} | null | undefined. Changes in TypeScript 4.8 enable noticeable improvements to control flow and type shrinkage, Microsoft said. Generic values ​​are also reduced.

As for file watch fixes, TypeScript had a long-standing bug where the language struggled with certain file changes in --watch mode and editor scenarios. They occur frequently on Unix systems. The situation was caused by assumptions about how Node.js handles renaming events in file systems. The 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 observer objects if it detects that a path still exists on disk, so it would end up reusing the observer object instead of installing a new observer in the original location and watching the changes made to what might be an irrelevant file. TypeScript 4.8 correctly handles these cases on inode systems and installs a new watcher.

Elsewhere in TypeScript 4.8:

  • Optimizations have been introduced to speed up scenarios around –-watch and --incremental, as well as project references using --build.
  • Inference from binding models has been improved.
  • When running all references in an editor, TypeScript is now smarter at aggregating references. This reduced the time it takes to search for a widely used ID by about 20%.
  • During a change with break, the unconstrained generics are no longer attributable to {}. In another breaking change, types cannot be imported or exported to JavaScript files.

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

npm install -D [email protected]

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

Copyright © 2022 IDG Communications, Inc.

Previous Global Enterprise File Sync and Sharing (EFSS)
Next Webcast Series: From URL to IRL: Why Digital Native Brands Become Bricks and Mortar | United States