Microsoft is releasing the latest version of TypeScript. TypeScript 3.9 introduces speed improvements to the compiler and editing experience and reduces bugs and crashes.
The team accepted a number of pull requests that optimize speed, each of which should reduce compile times by 5-10%. “Our team has been focusing on performance after observing extremely poor editing/compilation speed with packages like material-ui and styled-components. We’ve dived deep here, with a series of different pull requests that optimize certain pathological cases involving large unions, intersections, conditional types, and mapped types,” Microsoft wrote in a post.
In recent versions of TypeScript, Microsoft had introduced updates to declarations of functions like Promise.all and Promise.race, but those updates introduced regressions when mixing values with null or undefined. Microsoft accepted a pull request that had been submitted by Jack Bates, which fixes this issue, and that is available in this new release.
RELATED CONTENT: TypeScript 3.8 is now available
Another new feature is the addition of // @ts-expect-error comments. When a line of code is prefaced with this type of comment, TypeScript will prevent an error from being reported. If there is no error, it will notify the developer that // @ts-expect-error was not necessary. This comment acts similarly to // @ts-ignore, however, // @ts-ignore does nothing when the line of code doesn’t have an error. Microsoft has compiled a list of appropriate use cases for each type of comment in their TypeScript 3.9 announcement post.
The TypeScript team has also expanded error reporting on uncalled function checks to ternary conditionals. Previously, the feature only applied to conditions in if statements.
In addition, Microsoft introduced a number of breaking changes in this release to be aware of. More information about those can be read in Microsoft’s announcement.