TypeScript 4.8 shines on intersection and union types

TypeScript 4.8 shines on intersection and union types

TypeScript 4.8, the latest upgrade to Microsoft’s strongly typed JavaScript variant, has reached production availability as of August 25. The new version brings correctness and consistency improvements, along with fixes to file watching on Linux and MacOS.

[ Also on InfoWorld: 8 new JavaScript features to start using today ]

TypeScript 4.8 introduces improvements to consistency and correctness under strictNullChecks. These changes affect how intersection and union types function and are leveraged in how TypeScript narrows types. In one example, 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. Changes in TypeScript 4.8 allow for sensible improvements in control flow and type narrowing, Microsoft said. Generic values also get narrowed.

To read this article in full, please click here