v5.8-rc
Breaking Changes📦 typescriptView on GitHub →
⚠ 2 breaking✨ 5 features🐛 1 fixes⚡ 1 deprecations🔧 6 symbols
Summary
TypeScript 5.8 introduces the --erasableSyntaxOnly flag, improves type checking for conditional return expressions, and updates import attribute requirements to align with modern Node.js standards.
⚠️ Breaking Changes
- Restrictions on Import Assertions: The legacy 'assert' syntax for import attributes now triggers an error when used with 'type: module' in Node.js. Use the 'with' keyword instead.
- Stricter checks for 'use strict' in modules: TypeScript now correctly identifies that modules are always in strict mode, which may surface new errors in code that previously relied on non-strict behavior.
Migration Steps
- Update import attribute syntax from 'assert { type: "json" }' to 'with { type: "json" }'.
- If using --erasableSyntaxOnly, refactor code to remove enums, namespaces, and constructor parameter properties.
- Review return statements where conditional logic was previously inferred as a union of types.
✨ New Features
- Granular Evaluation of Branching in Return Expressions: Improved type inference for conditional (ternary) operators and logical expressions in return statements.
- Support for --module node18: A new module target to specifically match Node.js 18 behavior.
- The --erasableSyntaxOnly flag: Ensures TypeScript files only use syntax that can be easily stripped (no enums, namespaces, or parameter properties) for faster builds.
- Improved Support for require() of ECMAScript Modules in Node.js: Better interoperability when loading ESM from CJS under specific Node.js flags.
- Preserved Computed Property Names: TypeScript now preserves the literal types of computed property names in classes and object literals more accurately.
🐛 Bug Fixes
- Fixed various issues related to milestone 5.8.0 (Beta) and 5.8.1 (RC) as tracked in the GitHub issue tracker.
🔧 Affected Symbols
--module--erasableSyntaxOnlyimportrequireassertwith⚡ Deprecations
- The 'assert' keyword in import attributes is deprecated in favor of 'with'.