This article is more than 1 year old
Ever wondered why that one weird file keeps being included? Super sleuth TypeScript 4.2 is here
You again! That uninvited guest that just keeps turning up...
Microsoft has updated TypeScript to version 4.2 and a flag has been added to answer the age-old question: "just why is that file there?"
Among the tweaks in the update of the JavaScript superset (notable for static types and typo-catching type checking) is the arrival of the --explainFiles
flag to force the TypeScript compiler to explain itself after files that a developer had hit with exclude
still turn up in a program.
More than once we've scratched our heads and wondered exactly why certain files persist in turning up. "Inferring the files of your program," explained Microsoft, "turns out to be a complicated process."
Indeed it does and, while the new flag is welcome, the output format (which you'll probably want to pipe somewhere) is a little dense and "might change over time."
Program manager for TypeScript Daniel Rosenwasser also highlighted other improvements, including type aliases, stricter check for the in
operator and abstract
construct signatures. In addition, improvements were made around uncalled function checks in logical expressions (which now apply within &&
and ||
expressions) and changes around string index signatures.
In terms of breaking changes there are the usual tweaks to lib.d.ts
to catch out the unwary (Rosenwasser highlighted changes to Intl
and ResizeObserver
as potentially being the most disruptive.) The triggering of an error for import paths with a .d.ts
might also cause a few problems, as could the different type now needed for the lift
callback in visitNode
.
The first beta of version 4.3 is scheduled to hit next month, with a release scheduled for May. In the meantime, those seeking a stronger typed JavaScript world can download TypeScript 4.2 via NuGet or npm or pop it on for Visual Studio 2017 or 2019. Access can also be gained through the Insiders version of Visual Studio Code.
While not earth-shattering, version 4.2 is a useful update to a popular JavaScript extension and worth taking for a spin (if only to find out what those mystery files keep being added if nothing else.) ®