BT

InfoQ Homepage News TypeScript 3.9 Improves Performance, Promises and Errors

TypeScript 3.9 Improves Performance, Promises and Errors

Bookmarks

The TypeScript team announced the release of TypeScript 3.9, which includes improvements in inference with Promise.all, compiler checking speed, the @ts-expect-error comment, and more in the final major version before TypeScript 4.0.

TypeScript 3.9 fixes an issue introduced by TypeScript 3.7's updated type declarations for Promise.all and Promise.race. The TypeScript team was hoping to include the new awaited type to accurately model Promise unwrapping in JavaScript. As explained by Daniel Rosenwasser, program manager of the TypeScript team:

We initially anticipated shipping awaited in TypeScript 3.9, but as we’ve run early TypeScript builds with existing codebases, we’ve realized that the feature needs more design work before we can roll it out to everyone smoothly. As a result, we’ve decided to pull the feature out of our main branch until we feel more confident. We’ll be experimenting more with the feature, but we won’t be shipping it as part of this release.

The TypeScript 3.9 release also improves compiler speed for patterns found in packages such as material-ui and styled-components. The improvements result from optimizing code paths involving large unions, intersections, conditional, and mapped types.

Based on feedback from the Visual Studio Code team, renaming a file and updating all relevant import statements could take 5 to 10 seconds for large projects. TypeScript 3.9 changes the internals of the compiler and language service caches for file lookups, significantly reducing this time.

One challenge in writing tests with TypeScript was writing a block of code that is intentionally expected to error. Previously developers would need to use the @ts-ignore comment to prevent the compiler from failing on the relevant block of code. TypeScript 3.9 introduces the @ts-expect-error comment to indicate that the block of code is not only expected to introduce an error, but the compiler will warn if the commented block of code does not introduce an error.

The TypeScript 3.9 release includes numerous other minor additions, bug fixes, and editor experience improvements. A few breaking changes were added as part of these improvements:

  • parsing differences in optional chaining and non-null assertions
  • } and > are invalid JSX/TSX text characters
  • stricter checks on intersections and optional properties
  • intersections reduced by discriminant properties
  • getters/setters are no longer enumerable
  • type parameters that extend any no longer act as any
  • export * is always retained

See the TypeScript 3.9 release for full details on these breaking changes.

Work is already underway for TypeScript 4.0, expected in August 2020. Some of the TypeScript 4.0 release goals include the awaited type, labeled tuple elements, forward declarations, and much more.

TypeScript is open source software available under the Apache 2 license. Contributions and feedback are encouraged via the TypeScript GitHub project and should follow the TypeScript contribution guidelines and Microsoft open-source code of conduct.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.