Microsoft 11819 Published by

Microsoft has announced the release of TypeScript 5.8, a language that builds on top of JavaScript by adding syntax for types. It allows for more granular checks for branches within return expressions, which were not documented in the beta post but will remain in TypeScript 5.8.

The type system special-cases conditional expressions directly inside return statements, checking against the declared return type of the containing functions. TypeScript 5.8 also supports the require() of ECMAScript modules in the --module nodenext flag, allowing TypeScript to avoid issuing errors on require() calls to ESM files. This feature may be back-ported to older versions of Node.js, but future versions may stabilize the feature under node20. Users of Node.js 22 and newer should use the --module nodenext flag, while library authors and users of older versions should remain on the --module node16 or minor update to the --module node18 flag.





Node.js 5 has introduced several changes to improve its TypeScript capabilities. The erasableSyntaxOnly option allows TypeScript to error on most TypeScript-specific constructs that have runtime behavior. The --libReplacement flag allows users to disable the default lib files and ensures that node_modules are properly imported. The preserved computed property names in declaration files are now preserved, making them more predictable. This change is expected to make computed properties more predictable in declaration emit. However, it is important to note that this change may not be backward compatible with TypeScript 5.7 or earlier. The changes are expected to improve the overall functionality of TypeScript in the future.

TypeScript 5.8 introduces optimizations to improve program load times and update times. It avoids array allocations and re-validates options when editing without changing the project's structure. Notable behavioral changes include lib.d.ts types affecting type-checking, and restrictions on import assertions under --module nodenext. TypeScript 5.9 will feature more details and target dates. Early versions can be tested using npm or the VS Code TypeScript Nightly extension. The next version will be TypeScript 5.9, with more details to be announced in an upcoming iteration plan.

Announcing TypeScript 5.8

Today we’re excited to announce the release of TypeScript 5.8!

If you’re not familiar with TypeScript, it’s a language that builds on top of JavaScript by adding syntax for types. Writing types in our code allows us to explain intent and have other tools check our code to catch mistakes like typos, issues with null and undefined, and more. Types also power TypeScript’s editor tooling like the auto-completion, code navigation, and refactorings that you might see in editors like Visual Studio and VS Code. In fact, TypeScript and its ecosystem powers the JavaScript experience in both of those editors as well!

Announcing TypeScript 5.8 - TypeScript