Microsoft has released the latest version of TypeScript, its language that builds on JavaScript and adds syntax for type. With TypeScript 4.6, users gain several new features.

Since the Release Candidate, the team at Microsoft has also worked to do some internal refactoring which has fixed certain issues, corrected a few error messages, and improved type-checking performance by 3% in some instances. 

Prior to this release, it was an error to contain any code at the beginning of a constructor if its containing class had any property initializers. TypeScript 4.6 makes it more lenient and permits other code to run before super(), while still making sure that super() occurs at the top-level before any references to this.

Additionally, with this release a signature can be declared with a rest parameter whose type is a discriminated union of tuples. This means that when the first argument is the string “str”, then the second argument must be a string or when the first argument is the string “num”, the second has to be a number. Also, in cases where TypeScript infers the type of a function from a certain kind of signature, it can now narrow parameters that depend on each other.

A few other noteworthy changes include that object rests drop unspreadable members from generic objects and that JavaScript files always receive grammar and binding errors. To learn more about these features, see the first and second implementing pull requests. 

For more information on this release, see here. If you’re interested in learning more about what is on track for TypeScript’s next release, visit the issue tracker and read the iteration plan for TypeScript 4.7.