You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+47Lines changed: 47 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,52 @@
1
1
# Changelog
2
2
3
+
## Unreleased
4
+
5
+
* Adjust esbuild's warning about undefined imports for TypeScript `import` equals declarations ([#3271](https://github.com/evanw/esbuild/issues/3271))
6
+
7
+
In JavaScript, accessing a missing property on an import namespace object is supposed to result in a value of `undefined` at run-time instead of an error at compile-time. This is something that esbuild warns you about by default because doing this can indicate a bug with your code. For example:
8
+
9
+
```js
10
+
// app.js
11
+
import*asstylesfrom'./styles'
12
+
console.log(styles.buton)
13
+
```
14
+
15
+
```js
16
+
// styles.js
17
+
export let button = {}
18
+
```
19
+
20
+
If you bundle `app.js`with esbuild you will get this:
21
+
22
+
```
23
+
▲ [WARNING] Import "buton" will always be undefined because there is no matching exportin"styles.js" [import-is-undefined]
24
+
25
+
app.js:2:19:
26
+
2 │ console.log(styles.buton)
27
+
│ ~~~~~
28
+
╵ button
29
+
30
+
Did you mean to import"button" instead?
31
+
32
+
styles.js:1:11:
33
+
1 │ exportlet button = {}
34
+
╵ ~~~~~~
35
+
```
36
+
37
+
However, there is TypeScript-only syntax for`import` equals declarations that can represent either a type import (which esbuild should ignore) or a value import (which esbuild should respect). Since esbuild doesn't have a type system, it tries to only respect `import` equals declarations that are actually used as values. Previously esbuild always generated this warning for unused imports referenced within `import` equals declarations even when the reference could be a type instead of a value. Starting with this release, esbuild will now only warn in this case if the import is actually used. Here is an example of some code that no longer causes an incorrect warning:
38
+
39
+
```ts
40
+
// app.ts
41
+
import * as styles from './styles'
42
+
import ButtonType = styles.Button
43
+
```
44
+
45
+
```ts
46
+
// styles.ts
47
+
export interface Button {}
48
+
```
49
+
3
50
## 0.18.16
4
51
5
52
* Fix a regression with whitespace inside `:is()` ([#3265](https://github.com/evanw/esbuild/issues/3265))
0 commit comments