The next version of TypeScript, 4.8, is currently in the release candidate stage (RC release).
"Between now and the stable release of TypeScript 4.8, we expect no further changes beyond critical bug fixes," said TypeScript senior program manager Daniel Rosenwasser in a blog post.
This phase will be short, according to the iteration plan: a "final test build" will be released later this week, and the final version will be officially released around August 23rd.
Not much has been added since 4.8 Beta, the main feature has a new TS server preference to exclude modules or libraries from the auto-import list for code completion.
One of the other changes is what the TypeScript team calls "an early pistol for JavaScript developers at best, and bugs in production code at worst".
This is where objects are compared to array literals. code show as below:
var things: any[] = Array();
if (things == []) {
//数组为空吗?
}
Similar code would work in Python, but JavaScript only considers objects equal if they point to the same instance.
TypeScript 4.8 will now report this code error: "This condition will always return 'false' because JavaScript compares objects by reference, not by value."
TypeScript now reports an error if comparing an object to text
According to the TypeScript team, "due to the nature of type system changes", breaking changes in TypeScript updates are almost inevitable.
TypeScript's purpose is to make it easier to catch bugs before deployment, so the "correctness fixes" in 4.8, including the above changes, are a good thing for developers and projects, even if they seem to throw new bugs.
Google's internal software team said in the beta report that "some changes to our TypeScript code were required to make it compile with TypeScript 4.8", although only a small number of libraries were affected. "We still support TS improvements".
The Google team said it tested object vs array, text comparisons: "We saw type errors similar to those mentioned in the release announcement", and "We want to add casts to any type to eliminate errors, and over time Apply appropriate fixes".
While adding "as any" to the code will work, doing so leaves a potential bug and is therefore not recommended - although with Google this issue affects only 0.006% of the libraries used.
Author: Field Chief
Related Reading:
TypeScript 4.5 released; will Android 12 be the last update?
Retirement is recommended! The father of JSON: JavaScript has hindered progress
Build a repeatable front-end development environment on Linux