Announcing TypeScript 6.0
Overview
TypeScript 6.0 announced as the last release based on the current JavaScript codebase. It's the bridge to TypeScript 7.0, which uses a new Go-based native compiler.
Major Transition: TypeScript 7.0 is "extremely close to completion" with native Go-based compiler. Users are encouraged to try the native preview now.
What's New in TypeScript 6.0
1. Less Context-Sensitivity on this-less Functions
TypeScript 6.0 fixes inference for methods without explicit this usage:
// Before: error because consume's y was 'unknown'
callIt({
consume(y) { return y.toFixed(); },
produce(x: number) { return x * 2; },
});
// Now works - if 'this' is never used, function is not contextually sensitive
2. Subpath Imports Starting with #/
Now supports Node.js subpath imports with #/ prefix:
{
"name": "my-package",
"imports": {
"#/*": "./dist/*"
}
}
// Now works:
import * as utils from "#/utils.js";
3. Module Resolution Bundler + CommonJS
Now supports combining --moduleResolution bundler with --module commonjs.
Deprecations
- Import assertion syntax (import ... assert {...}) deprecated
- Extended to import() calls: import(..., { assert: {...}})
TypeScript 7.0 Preview
The new Go-based compiler offers:
- Native code speed
- Shared-memory multi-threading
- Try in VS Code: vscode marketplace
- Or npm: npm install @typescript/native-preview
Significance
TypeScript 6.0 marks the end of an era for the JavaScript-based compiler and the start of a new native era. The transition to Go represents a major architectural change for TypeScript.