-
Fix parsing of casts in TypeScript followed by certain tokens
This aligns esbuild's TypeScript parser with the official TypeScript parser as far as parsing of
as
casts. It's not valid to form an expression after anas
cast if the next token is a(
,[
,++
,--
,?.
, assignment operator, or template literal. Previously esbuild wouldn't generate an error for these expressions. This is normally not a problem because the TypeScript compiler itself would reject the code as invalid. However, if the next token starts on a new line, that new token may be the start of another statement. In that case the code generated by esbuild was different than the code generated by the TypeScript compiler. This difference has been fixed. -
Implement wildcards for external paths (#406)
You can now use a
*
wildcard character with the--external
option to mark all files matching a certain pattern as external, which will remove them from the bundle. For example, you can now do--external:*.png
to remove all.png
files. When a*
wildcard character is present in an external path, that pattern will be applied to the original path in the source code instead of to the path after it has been resolved to a real file system path. This lets you match on paths that aren't real file system paths. -
Add a warning about self-assignment
This release adds a warning for code that assigns an identifier to itself (e.g.
x = x
). This code is likely a mistake since doing this has no effect. This warning is not generated for assignments to global variables, since that can have side effects, and self-assignments with TypeScript casts, since those can be useful for changing the type of a variable in TypeScript. The warning is also not generated for code inside anode_modules
folder.