v0.15.14
-
Fix parsing of TypeScript
infer
inside a conditionalextends
(#2675)Unlike JavaScript, parsing TypeScript sometimes requires backtracking. The
infer A
type operator can take an optional constraint of the forminfer A extends B
. However, this syntax conflicts with the similar conditional type operatorA extends B ? C : D
in cases where the syntax is combined, such asinfer A extends B ? C : D
. This is supposed to be parsed as(infer A) extends B ? C : D
. Previously esbuild incorrectly parsed this as(infer A extends B) ? C : D
instead, which is a parse error since the?:
conditional operator requires theextends
keyword as part of the conditional type. TypeScript disambiguates by speculatively parsing theextends
after theinfer
, but backtracking if a?
token is encountered afterward. With this release, esbuild should now do the same thing, so esbuild should now correctly parse these types. Here's a real-world example of such a type:type Normalized<T> = T extends Array<infer A extends object ? infer A : never> ? Dictionary<Normalized<A>> : { [P in keyof T]: T[P] extends Array<infer A extends object ? infer A : never> ? Dictionary<Normalized<A>> : Normalized<T[P]> }
-
Avoid unnecessary watch mode rebuilds when debug logging is enabled (#2661)
When debug-level logs are enabled (such as with
--log-level=debug
), esbuild's path resolution subsystem generates debug log messages that say something like "Read 20 entries for directory /home/user" to help you debug what esbuild's path resolution is doing. This caused esbuild's watch mode subsystem to add a dependency on the full list of entries in that directory since if that changes, the generated log message would also have to be updated. However, meant that on systems where a parent directory undergoes constant directory entry churn, esbuild's watch mode would continue to rebuild if--log-level=debug
was passed.With this release, these debug log messages are now generated by "peeking" at the file system state while bypassing esbuild's watch mode dependency tracking. So now watch mode doesn't consider the count of directory entries in these debug log messages to be a part of the build that needs to be kept up to date when the file system state changes.