Microsoft Ships TypeScript 4.6

Microsoft shipped TypeScript 4.6, listing these highlights:

  • Allowing Code in Constructors Before super(): TypeScript 4.6 is much more lenient in ensuring that super() is called before referring to this, no longer generating an error in certain circumstances while still ensuring that super() occurs at the top-level before any references to this.
  • Control Flow Analysis for Destructured Discriminated Unions: "When destructuring individual properties into a const declaration, or when destructuring a parameter into variables that are never assigned to, TypeScript will check for 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 So in our example, a check on kind narrows the type of payload."
  • Improved Recursion Depth Checks: This has to do with comparing object types for compatibility in a structural type system that allows for generics, effectively cleaning up some false negatives that could be discernible by a human looking at the code.
  • Indexed Access Inference Improvements: "TypeScript now can correctly infer to indexed access types which immediately index into a mapped object type."
  • Control Flow Analysis for Dependent Parameters: TypeScript can now narrow parameters that depend on each other n cases where TypeScript infers the type of a function from a signature declared with a rest parameter whose type is a discriminated union of tuples.
  • --target es2022: "TypeScript's --target option now supports es2022. This means features like class fields now have a stable output target where they can be preserved. It also means that new built-in functionality like the at() method on Arrays, Object.hasOwn, or the cause option on new Error can be used either with this new --target setting, or with --lib es2022."
  • Removed Unnecessary Arguments in react-jsx: This drops a void 0 that is unnecessarily generated in certain scenarios, decreasing bundle sizes.
  • JSDoc Name Suggestions: "TypeScript now provides suggestions for when parameter names don't match between your function and its JSDoc comment."
  • More Syntax and Binding Errors in JavaScript: New syntax and binding errors in JavaScript files can now be seen in Visual Studio or VS Code or when code is run through the TypeScript compiler. "These errors can be disabled by adding a // @ts-nocheck at the top of your file, but we're interested in hearing some early feedback about how it works for your JavaScript workflow."
  • TypeScript Trace Analyzer: A new tool provides a more readable view of the information provided by the generateTrace flag that identifies types that are computationally expensive to create and compare against other types.

The Feb. 28 announcement fleshes out all of the above in much greater detail and and also details breaking changes.

TypeScript 4.7 Iteration Plan
TypeScript 4.7 Iteration Plan (source: Microsoft).

Going forward, the TypeScript 4.7 Iteration Plan (pictured above) shows what's on tap for the next edition, due to debut on May 24.

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus


  • What's Next for ASP.NET Core and Blazor

    Since its inception as an intriguing experiment in leveraging WebAssembly to enable dynamic web development with C#, Blazor has evolved into a mature, fully featured framework. Integral to the ASP.NET Core ecosystem, Blazor offers developers a unique combination of server-side rendering and rich client-side interactivity.

  • Nearest Centroid Classification for Numeric Data Using C#

    Here's a complete end-to-end demo of what Dr. James McCaffrey of Microsoft Research says is arguably the simplest possible classification technique.

  • .NET MAUI in VS Code Goes GA

    Visual Studio Code's .NET MAUI workload, which evolves the former Xamarin.Forms mobile-centric framework by adding support for creating desktop applications, has reached general availability.

  • Visual Studio Devs Quick to Sound Off on Automatic Updates: 'Please No'

    A five-year-old Visual Studio feature request for automatic IDE updates is finally getting enacted by Microsoft amid a lot of initial developer pushback, seemingly misplaced.

  • First Official OpenAI Library for .NET Goes Beta

    Although it seems Microsoft and OpenAI have been deeply intertwined partners for a long time, they are only now getting around to releasing an official OpenAI library for .NET developers, joining existing community libraries.

Subscribe on YouTube