Paul Krill
Editor at Large

TypeScript 5.6 now generally available

news
Sep 11, 20243 mins
JavaScriptProgramming LanguagesSoftware Development

Update of Microsoft’s strongly typed JavaScript disallows nullish and truthy checks on syntax that never varies on nullishness or truthiness.

Letters, type, code
Credit: Daboost/Shutterstock

TypeScript 5.6, the latest version of Microsoft’s strongly typed JavaScript variant, is now available as a production release. The update features capabilities that include disallowing nullish and truthy checks on syntax that never varies on nullishness or truthiness.

Unveiled September 9, TypeScript can be accessed via NPM using the following command: npm install -D -typescript. The update also can be accessed through NuGet.

For disallowed nullish and truthy checks, TypeScript’s compiler now errors when it can syntactically determine that a truthy or nullish check will always evaluate in a specific way. Microsoft said “many, many bugs” could be caught this way. Some expressions still are allowed even if truthy or nullish. Specifically, true, false, 0, and 1 are all still allowed despite always being truthy or falsy.

The production release of TypeScript 5.6 follows a release candidate published August 23 and a beta release that arrived July 26.

Also in TypeScript 5.6, Microsoft reverted a change around how TypeScript’s language service searched for tsconfig.json files. Previously, the language service would walk up the directory tree looking for every possible project file named tsconfig.json that could contain a file. Because this could lead to opening many referenced projects, Microsoft reverted the behavior. The company is investigating ways to bring the behavior back in TypeScript 5.7.

In another improvement, a feature called region-prioritized diagnostics or region-prioritized checking has been introduced. This addresses a situation in which the language service, when asked for diagnostics for a file, might incur delay when checking large files.

Also in TypeScript 5.6:

  • A new compiler option, called  --noUncheckedSideEffectImports, will throw an error if it cannot find a source file for a side effect import. Another new compiler option, --noCheck, will skip type checking for all input files.
  • New editor functionality has been added such as direct support for commit characters and exclude patterns for auto-imports.
  • Arbitrary module identifiers now can be used in code.
  • Previously, TypeScript offered a single type called BuiltinIterator to describe values backed by Iterator.prototype. This has been renamed IteratorObject and has several subtypes such as ArrayIterator and MapIterator.
  • A --stopOnBuildErrors flag has been added for --build mode. When a project builds with any errors, no other projects will continue to be built.

TypeScript 5.6 follows the June 20 release of TypeScript 5.5, which introduced inferred type predicates and regular expression checking. TypeScript 5.7, meanwhile, is due in beta on October 1, with capabilities such as enforcing read-only checks on object members.