esbuild 0.11.21
-
TypeScript
overridefor parameter properties (#1262)You can now use the
overridekeyword instead of or in addition to thepublic,private,protected, andreadonlykeywords for declaring a TypeScript parameter property:class Derived extends Base { constructor(override field: any) { } }This feature was recently added to the TypeScript compiler and will presumably be in an upcoming version of the TypeScript language. Support for this feature in esbuild was contributed by @g-plane.
-
Fix duplicate export errors due to TypeScript import-equals statements (#1283)
TypeScript has a special import-equals statement that is not part of JavaScript. It looks like this:
import a = foo.a import b = a.b import c = b.c import x = foo.x import y = x.y import z = y.z export let bar = cEach import can be a type or a value and type-only imports need to be eliminated when converting this code to JavaScript, since types do not exist at run-time. The TypeScript compiler generates the following JavaScript code for this example:
var a = foo.a; var b = a.b; var c = b.c; export let bar = c;The
x,y, andzimport statements are eliminated in esbuild by iterating over imports and exports multiple times and continuing to remove unused TypeScript import-equals statements until none are left. The first pass removeszand marksyas unused, the second pass removesyand marksxas unused, and the third pass removesx.However, this had the side effect of making esbuild incorrectly think that a single export is exported twice (because it's processed more than once). This release fixes that bug by only iterating multiple times over imports, not exports. There should no longer be duplicate export errors for this case.
-
Add support for type-only TypeScript import-equals statements (#1285)
This adds support for the following new TypeScript syntax that was added in version 4.2:
import type React = require('react')Unlike
import React = require('react'), this statement is a type declaration instead of a value declaration and should be omitted from the generated code. See microsoft/TypeScript#41573 for details. This feature was contributed by @g-plane.