Can't find variable _ after upgrading to Next 12.3
See original GitHub issueVerify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 21.6.0: Wed Aug 10 14:25:27 PDT 2022; root:xnu-8020.141.5~2/RELEASE_X86_64 Binaries: Node: 16.13.1 npm: 6.14.8 Yarn: 1.22.19 pnpm: N/A Relevant packages: next: 12.3.0 eslint-config-next: 11.1.2 react: 17.0.2 react-dom: 17.0.2
What browser are you using? (if relevant)
Reproduced with Firefox 104.0.1 and Safari 15.6.1
How are you deploying your application? (if relevant)
No response
Describe the Bug
After upgrading to Next 12.3 this morning, I’ve immediately had a console error saying “Can’t find variable _”.
I’ve debugged my code, because it made no sense. I’ve upgraded Typescript, no change.
I’ve finally fixed it by finding the _ variable that was created after compilation, create a new named variable and use it.
My code used to be:
switch (component.type) {
it’s now:
let componentType: string = component.type;
switch (componentType) {
It is a silly thing, but I’ve lost plenty of time because of this, and I’m still unclear what’s the root cause.
Expected Behavior
No error after compilation.
Link to reproduction
It’s a private repo
To Reproduce
Hard to say how to reproduce outside of the code that is provided above. Let me know if I can provide anything more helpful.
Issue Analytics
- State:
- Created a year ago
- Reactions:5
- Comments:6 (4 by maintainers)
Just disscussed the issue with some SWC contributors. It seems that issue might be related with SWC’s recent generator transpiling changes.
Using the reproduction from #40405 indeed, it seems to be an SWC issue.