|
1 | | -# TypeScript 5.9.2 |
| 1 | +## TypeScript 5.9.2 |
| 2 | + |
| 3 | +### **Minimal and Updated `tsc --init`** |
| 4 | + |
| 5 | +The TypeScript compiler now generates a more streamlined `tsconfig.json` with better defaults: [details](https://devblogs.microsoft.com/typescript/announcing-typescript-5-9/#minimal-and-updated-tsc---init) |
| 6 | + |
| 7 | +### **Support for `import defer`** |
| 8 | + |
| 9 | +TypeScript 5.9 introduces support for ECMAScript's deferred module evaluation proposal using the new `import defer` syntax. This feature allows you to import a module without immediately executing the module and its dependencies, providing better control over when work and side-effects occur. |
| 10 | + |
| 11 | +**Key Benefits:** |
| 12 | + |
| 13 | +- Module evaluation is deferred until you access a property of the imported namespace |
| 14 | +- Only namespace imports are supported: `import defer * as feature from "./some-feature.js"` |
| 15 | +- Useful for conditionally loading modules with expensive initialization |
| 16 | +- Can improve startup performance by deferring module evaluation until needed |
| 17 | + |
| 18 | +**Usage Example:** |
| 19 | + |
| 20 | +```typescript |
| 21 | +import defer * as feature from "./some-feature.js"; |
| 22 | + |
| 23 | +// No side effects have occurred yet |
| 24 | +// Module is only evaluated when accessing a property: |
| 25 | +console.log(feature.specialConstant); // Now side effects occur |
| 26 | +``` |
| 27 | + |
| 28 | +**Limitations:** |
| 29 | + |
| 30 | +- Only works with `--module` modes `preserve` and `esnext` |
| 31 | +- Not transformed by TypeScript - requires runtime support or bundler transformation |
| 32 | +- Named imports and default imports are not supported |
| 33 | + |
| 34 | +### **Summary Descriptions in DOM APIs** |
| 35 | + |
| 36 | +TypeScript now includes summary descriptions for many DOM APIs based on MDN documentation, providing quick context without needing to visit external documentation. |
| 37 | + |
| 38 | +### **Expandable Hovers (Preview)** |
| 39 | + |
| 40 | +New preview feature that allows expanding quick info tooltips to see deeper type information with configurable maximum hover length. |
| 41 | + |
| 42 | +### **Performance Optimizations** with cache instantiations on mappers and file system optimizations |
| 43 | + |
| 44 | +### **Notable Behavioral Changes**: **lib.d.ts Changes** |
| 45 | + |
| 46 | +- `ArrayBuffer` is no longer a supertype of `TypedArray` types |
| 47 | +- May affect code using `Buffer` from Node.js with `ArrayBuffer` types |
| 48 | +- New error messages for type mismatches between `ArrayBufferLike` and `BufferSource` |
| 49 | + |
| 50 | +## **Migration Notes** |
| 51 | + |
| 52 | +- Review any code using `ArrayBuffer` with `TypedArray` or `Buffer` types |
| 53 | +- Consider updating `tsconfig.json` files to use new defaults |
| 54 | +- Test expandable hovers feature in your editor |
| 55 | +- Update hover length settings if needed |
| 56 | + |
| 57 | +## **Resources** |
| 58 | + |
| 59 | +- [TypeScript 5.9 Release Notes](https://devblogs.microsoft.com/typescript/announcing-typescript-5-9/) |
| 60 | +- [TypeScript Configuration Reference](https://www.typescriptlang.org/tsconfig/) |
0 commit comments