Commit a59584f
authored
Avoid removeNewlyUnusedIdentifiers when encountering destructuring (#161)
In 0.14.6, I ran into the following error when updating in a project:
> Cannot read property 'referencePaths' of undefined at
> VariableDeclarator, lib/index.js:292:56
I have so far been unable to reproduce this in our test suite, but I can
reproduce it in a local repo by using `npm link`. I wonder if this could
be a weird interaction of multiple babel plugins.
It seems that in the case I am encountering, the VariableDeclarator has
an id of type ObjectPattern, which means that there is some object
destructuring happening.
We should ideally take care to clean up the destructuring in the same
way that we clean up other variable usage, but I think that will be a
little more complicated than what I have time for right now, so as a
quick fix, I am escaping from this function in this case.
In my local testing, this prevents the plugin from crashing and produces
the same result as before.1 parent fb3c061 commit a59584f
1 file changed
+14
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
292 | 298 | | |
293 | 299 | | |
| 300 | + | |
294 | 301 | | |
295 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
296 | 307 | | |
297 | 308 | | |
298 | 309 | | |
| |||
310 | 321 | | |
311 | 322 | | |
312 | 323 | | |
313 | | - | |
| 324 | + | |
314 | 325 | | |
315 | 326 | | |
316 | 327 | | |
| |||
0 commit comments