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

  • Hands On: New VS Code Insiders Build Creates Web Page from Image in Seconds

    New Vision support with GitHub Copilot in the latest Visual Studio Code Insiders build takes a user-supplied mockup image and creates a web page from it in seconds, handling all the HTML and CSS.

  • Naive Bayes Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the naive Bayes regression technique, where the goal is to predict a single numeric value. Compared to other machine learning regression techniques, naive Bayes regression is usually less accurate, but is simple, easy to implement and customize, works on both large and small datasets, is highly interpretable, and doesn't require tuning any hyperparameters.

  • VS Code Copilot Previews New GPT-4o AI Code Completion Model

    The 4o upgrade includes additional training on more than 275,000 high-quality public repositories in over 30 popular programming languages, said Microsoft-owned GitHub, which created the original "AI pair programmer" years ago.

  • Microsoft's Rust Embrace Continues with Azure SDK Beta

    "Rust's strong type system and ownership model help prevent common programming errors such as null pointer dereferencing and buffer overflows, leading to more secure and stable code."

  • Xcode IDE from Microsoft Archrival Apple Gets Copilot AI

    Just after expanding the reach of its Copilot AI coding assistant to the open-source Eclipse IDE, Microsoft showcased how it's going even further, providing details about a preview version for the Xcode IDE from archrival Apple.

Subscribe on YouTube

Upcoming Training Events