|TypeScript 4.6 Improves Constructors|
|Written by Kay Ewbank|
|Thursday, 03 March 2022|
TypeScript 4.6 has been released with improvements including the ability to have code before super() in constructors, and control flow analysis for destructured discriminated unions.
Another improvement is the addition of control flow analysis for destructured discriminated unions. TypeScript can use discriminant properties to narrow the type analysis. If an individual property is destructured into a const declaration, TypeScript checks to see if the destructured type is a discriminated union. If it is, TypeScript can now narrow the types of variables depending on checks of other variables
Other improvements include improved recursion depth checks and improvements to indexed access types meaning that TypeScript can now correctly infer to indexed access types which immediately index into a mapped object type.
There's also a new tool called the TypeScript Trace Analyzer. This gives a better view of the analysis showing when a type could be computationally expensive to create and compare against other types.
TypeScript 4.6 is available now.
or email your comment to: firstname.lastname@example.org