The 4.0 release is technically a major milestone with a host of new features. However, according to TypeScript's creator, Anders Hejlsberg, a technical fellow at Microsoft, it's just the culmination of work his team has been focusing on since TypeScript 3.0 was released two years ago.
"It's funny. We were joking that 4.0, well, it just so happens to be what comes after 3.9 and literally if you look at our release history… yes we hit round numbers every 10 releases and we hit 3.0 about two years ago," Hejlsberg told ZDNet.
"But of course in a sense a good way to look at it is as what's happened in those two years since 3.0."
SEE: Hiring Kit: Python developer (TechRepublic Premium)
Hejlsberg says there are several main themes driving changes in TypeScript, including the experience with editors like Microsoft's Visual Studio Code editor, better error messages and better refactoring.
"We've worked a lot on performance, scalability, because people are starting to build really large projects in TypeScript and they still want this super-snappy performance on a project with hundreds of thousands of lines of code in it – and that's not an easy problem to solve."
One of the performance improvements in TypeScript 4.0 addresses slow startup times on bigger projects.
Daniel Rosenwasser of the TypeScript team explains that the culprit is usually a process called 'project loading', where multiple dependencies are resolving. So the team has been working on a partial editing mode at startup.
"The core idea is that editors can run a lightweight partial server that only looks at the current files that the editor has open," he notes. "This has always been an option for editors, but TypeScript 4.0 expands the functionality on that server to some semantic operations – as opposed to just syntactic operations, which was previously the case."
While this limits the information available, it's enough for basic code completion and other quick information when an editor is first opened up.
According to Rosenwasser, he's seen machines take up to a minute before TypeScript is responsive on a file in VS Code but the new mode in TypeScript 4.0 cuts the time to responsiveness down to a few seconds.
Among the many other improvements in TypeScript 4.0 are smarter auto-imports to help when auto-imports doesn't work as expected and harms developer productivity. One stumbling block was that auto-imports sometimes would work on packages that were written in TypeScript.
"TypeScript 4.0 now does a little extra work in editor scenarios to include a limited number of packages you've listed in your package.json's dependencies field," notes Rosenwasser.
"The information from these packages is only used to improve auto-imports, and doesn't change anything else like type-checking. This helps alleviate the cost of walking through your node_modules directories while still fixing one of the most common problems we've heard for new projects."