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


  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube