Repository navigation
Commit 0c279a8
committed
fix(define): preserve non-optional property access past undefined member
When an object member defined via DefinePlugin resolves to undefined,
accessing properties non-optionally past that member was unconditionally
collapsed into undefined by expressionMemberChain.
At runtime, reading a property off undefined must throw a TypeError.
We now cut the chain at the undefined member using dropTrailingMembers
when the access is not optional, emitting (undefined).a so the
runtime TypeError is preserved natively.
Fixes #220141 parent 15beefc commit 0c279a8
3 files changed
Lines changed: 33 additions & 4 deletions
File tree
- lib
- test/configCases/plugins
- define-plugin-optional-chaining
- define-plugin
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1220 | 1220 | | |
1221 | 1221 | | |
1222 | 1222 | | |
1223 | | - | |
| 1223 | + | |
1224 | 1224 | | |
1225 | | - | |
| 1225 | + | |
| 1226 | + | |
1226 | 1227 | | |
1227 | | - | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
1228 | 1240 | | |
1229 | 1241 | | |
1230 | 1242 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
85 | 101 | | |
86 | 102 | | |
87 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
| 162 | + | |
162 | 163 | | |
163 | 164 | | |
164 | 165 | | |
| |||
0 commit comments