v5.8.2
Breaking Changes📦 typescriptView on GitHub →
⚠ 3 breaking✨ 5 features🐛 3 fixes⚡ 1 deprecations🔧 5 symbols
Summary
TypeScript 5.8 introduces the 'erasableSyntaxOnly' flag, support for 'require()' of ESM in Node.js, and stricter checks for 'use strict' prologues. It focuses on performance optimizations and better compatibility with modern JavaScript runtimes.
⚠️ Breaking Changes
- Granular checks for 'use strict' in files: TypeScript now strictly enforces that certain prologue-disallowed constructs (like octal literals) cannot exist before 'use strict' in ESM files.
- Restrictions on Import Assertions: The deprecated 'assert' syntax for import attributes now triggers a warning/error in favor of 'with'.
- Stricter return type inference for conditional expressions may catch previously unflagged type mismatches.
Migration Steps
- Update 'assert' keywords in import statements to 'with'.
- Ensure that no code precedes 'use strict' directives in files intended to be emitted as modules.
- If using simple transpilers, consider enabling the 'erasableSyntaxOnly' flag to catch incompatible syntax early.
✨ New Features
- Granular 'use strict' checking.
- Support for 'erasableSyntaxOnly' to ensure files can be compiled by simple transpilers like esbuild or swc.
- Improved support for 'module': 'node18' and 'nodenext' with better resolution for ESM/CJS boundaries.
- Optimized build performance through improved incremental parsing.
- Support for 'require()' of ECMAScript modules in Node.js under specific conditions.
🐛 Bug Fixes
- Fixed various issues related to template literal type inference.
- Resolved crashes in the TSServer when handling large monorepos.
- Corrected behavior of 'preserveValueImports' when used with 'isolatedModules'.
🔧 Affected Symbols
erasableSyntaxOnlymodulemoduleResolutionimportrequire⚡ Deprecations
- Import Assertions (using the 'assert' keyword) are now deprecated in favor of Import Attributes (using the 'with' keyword).