TypeScript 4.8 has been released with a number of correctness and consistency improvements that affect how intersection and union types work. The changes are used by TypeScript to narrow types.
TypeScript is a superset of JavaScript that adds optional static types which can be checked by the TypeScript compiler to catch common errors in your programs. TypeScript can use this information to help you avoid about mistakes like typos, missing arguments, or forgetting to check for null and undefined.
The improvements to managing correctness and consistency improvements under --strictNullChecks in the latest release affect how intersection and union types work. The team says that unknown is close in spirit to the union type {} | null | undefined because it accepts null, undefined, and any other type. TypeScript now recognizes this, and allows assignments from unknown to {} | null | undefined.
Another change means that NonNullable can use an intersection with {}, because {} & null and {} & undefined are discarded, meaning that {} intersected with any other object type simplifies to that object type. This is an improvement because intersection types like this can be reduced and assigned to, while conditional types currently cannot. The developers say that the changes also support "sensible improvements in control flow analysis and type narrowing".
Another improvement in the new release fixes a long-standing bug that until now has caused problems when some changes occurred in files in --watch mode and editor scenarios. This sometimes manifested as displaying stale or inaccurate errors that might show up that require restarting tsc or VS Code. Developers reported the problems more on Unix systems, especially after saving a file with vim or swapping branches in git.
TypeScript 4.8 should no longer manifest the problem thanks to reworking of how it decides when to use a new watcher.
Other improvements include faster running of "find-all-references" in the editor. Because of a change to make TypeScript smarter as it aggregates references, the team says you should see improvements of about 20 percent in the time taken.
TypeScript 4.8 is available now.
- Ian Elliot is the author of Just JavaScript: An Idiomatic Approach ; JavaScript Async ; Just jQuery: The Core UI ;Just jQuery: Events, Async & AJAX and JavaScript Bitmap Graphics with Canvas. All these titles are part of theI Programmer Librarypublished by I/O Press .
More Information
Related Articles
TypeScript 4.7 Adds Node.js ECMAScript Module Support
TypeScript 4.6 Improves Constructors
TypeScript 4.4 Improves Control Flow Analysis
TypeScript 4.3 Adds Separate Property Write Types
TypeScript 4.2 Release Candidate Available
New TypeScript Website Launched
TypeScript 4.1 Adds Temporal Literal Types
To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Google Tunix Hack Hackathon Now Open
14/11/2025
A Google hackathon on Kaggle is now open for entries showing how to use Tunix, Google's JAX-native library for LLM post-training, to train a model to show its work by laying out a reasoning trace befo [ ... ]
Blockly Moving To Raspberry Pi Foundation
31/10/2025
Blockly is moving to a new home. Having originated as a single-person project at Google in 2011, it is now a vibrant open source project which has moved into robotics as well as being at the heart of [ ... ]
- AI Improves Devs Skills, Enhances Their Roles
- The Pico Gets Zephyr And Rust Support
- Missing The Point Of LLMs
- Robotic Gut Spider For Exploring Digestive Tract
- Eclipse Foundation Adds Agentic Functionality To Eclipse LMOS
- Windows XP Crocs Now On Sale
- AI Champion Ship Now Open
- The Fuss About Fil-C...
- Linkerd Adds MCP Support
- Vibe Coding Is Collins Word of the Year 2025
- InfluxDB 3.6 Released With AI Capabilities
- DH2i Launches DxEnterprise For SQL Server 2025
- OpenCode - The Claude Code Alternative
Comments
or email your comment to: comments@i-programmer.info
<ASIN:1871962579>
<ASIN:B07S8958R9>
<ASIN:1871962560>
<ASIN:1871962501>
<ASIN:1871962528>
<ASIN:1871962625>