TypeScript 4.8 is now a Release Candidate, fixes ‘early foot-gun for JavaScript developers’

TypeScript 4.8 is now a Release Candidate, fixes ‘early foot-gun for JavaScript developers’

The next version of TypeScript, 4.8, is now at Release Candidate stage. “Between now and the stable release of TypeScript 4.8, we expect no further changes apart from critical bug fixes,” said senior program manager Daniel Rosenwasser in a post.

This phase is a short one, and according to the iteration plan a “final build for testing” will come later this week and a final release on August 23rd or thereabouts. Not much has been added since the beta, though there is a new TS Server preference to exclude modules or libraries from the auto-imports list used for code completion.

Among the other changes is one that the TypeScript team called “at best an early foot-gun for JavaScript developers, and at worst a bug in production code.” This is where an object is compared to an array literal, for example like this:

var things: any[] = Array();

if (things == []) {

//array is empty?


Similar code works in Python but JavaScript only regards objects as equal if they point to the same instance. TypeScript 4.8 now reports an error on this code “This condition will always return ‘false’ since JavaScript compares objects by reference, not value.”

TypeScript now reports an error if an object is compared to a literal

According to the TypeScript team, breaking changes in TypeScript updates are near-inevitable, “due to the nature of type system changes.” The purpose of TypeScript is to make it easier to catch errors before they are deployed so the “correctness fixes” in 4.8, which includes the above as well as other changes, are a good thing even if they appear to raise new errors.

Reporting on the beta Google’s internal software team said that “some changes to our TypeScript code are required to make it compile with TS 4.8” though with only a small percentage of its libraries affected. “We support the typing improvements. Generally it’s clear what’s changing,” the post added.

The Google team said, regarding the comparison of objects to array literals, that “we see type errors similar to the ones mentioned in the release announcement” and that “we expect to add casts to any to silence the error and apply proper fixes over time.”

Although peppering the code with “as any” will work, doing so will leave the potential for errors in place so it is not recommended – though in Google’s case, it only affects 0.006 percent of the libraries it uses, according to the post.