News

TypeScript 4.3 Ships

TypeScript 4.3 is out, adding a bevy of new features and functionality to Microsoft's popular programming language that builds on JavaScript by adding syntax for static types.

Here's a look at some of the highlights of the release as explained in a blog post this week authored by program manager Daniel Rosenwasser:

  • Separate Write Types on Properties: This has to do with APIs that convert passed-in values before storing them. Problems can arise when modeling those APIs in code. "If we really want to model APIs that convert values, previous versions of TypeScript forced us to pick between being precise (which makes reading values easier, and writing harder) and being permissive (which makes writing values easier, and reading harder)." Thus v4.3 lets developers specify types for reading and writing to properties. More on this is available in a pull request.
  • override and the --noImplicitOverride Flag: This addresses mistakes that can happen when overriding methods, for example when a base class is updated and the update isn't effected in another class that extends it. "Part of the issue here is that a user can't make it clear whether they meant to add a new method, or to override an existing one. That's why TypeScript 4.3 adds the override keyword." Thus when a method is marked with override, TypeScript ensures a method with the same name exists in the base class.

    "This is a big improvement, but it doesn't help if you forget to write override on a method -- and that's a big mistake users can run into also." Thus v4.3's --noImplicitOverride flag generates an error when any method from a superclass is overridden unless a developer explicitly uses an override keyword. More on this is available in a pull request.

  • Template String Type Improvements: These have to do with the recently introduced template string types that either construct new string-like types by concatenating or match patterns of other string-like types. "The first change we made is just in when TypeScript will infer a template string type. When a template string is contextually typed by a string-literal-like type (i.e. when TypeScript sees we're passing a template string to something that takes a literal type) it will try to give that expression a template type." Also, v4.3 can better relate, and infer between, different template string types, Rosenwasser said. More on these can be found on pull requests here and here.
  • ECMAScript #private Class Elements: v4.3 expands which elements in a class can be made truly private at run-time via #private #names, working for properties, methods and accessors. See this pull request for more.
  • ConstructorParameters Works on Abstract Classes: Pretty self-explanatory: The ConstructorParameters type helper now works on abstract classes. It's detailed in this pull request.

Other new features detailed by Rosenwasser include:

Looking forward to v4.4, Rosenwasser pointed to its iteration plan:

v4.4 Iteration Plan
[Click on image for larger view.] v4.4 Iteration Plan (source: Microsoft).

After several betas and RCs, it's expected to debut Aug. 24.

More details for v4.4 are included in the roadmap, which lists:

  • Generalized index signatures
  • Allow more code before super() calls in subclasses
  • Investigate typeof class
  • Use unknown as the type for catch clause variables

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube