Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Cannot set properties of undefined (setting 'identifier') error when using plugin-proposal-decorators legacy with plugin-transform-block-scoping #15295

Closed
1 task
charlessuh opened this issue Dec 22, 2022 · 15 comments
Labels
i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@charlessuh
Copy link
Contributor

charlessuh commented Dec 22, 2022

馃捇

  • Would you like to work on a fix?

How are you using Babel?

@babel/cli

Input code

try {
    class C {
        @Dummy foo() {
            throw new Error();
        }
    }

    let c = new C();
    c.foo();
} catch (e) {
    console.error(e);
}

Configuration file name

.babelrc

Configuration

{
  //"presets": [
  //  ["@babel/preset-env", {"targets": "firefox 50"}]
  //],
  "plugins": [
    ["@babel/plugin-proposal-decorators", {"legacy": true}],
    ["@babel/transform-block-scoping"]
  ]	
}

Current and expected behavior

Current:

TypeError: /Users/chsuh/decorators-bug/index.js: Cannot set properties of undefined (setting 'identifier')
    at PluginPass.ClassDeclaration (/Users/chsuh/decorators-bug/node_modules/@babel/plugin-proposal-decorators/lib/transformer-legacy.js:148:26)
    at newFn (/Users/chsuh/decorators-bug/node_modules/@babel/traverse/lib/visitors.js:159:21)
    at NodePath._call (/Users/chsuh/decorators-bug/node_modules/@babel/traverse/lib/path/context.js:46:20)
    at NodePath.call (/Users/chsuh/decorators-bug/node_modules/@babel/traverse/lib/path/context.js:36:17)
    at NodePath.visit (/Users/chsuh/decorators-bug/node_modules/@babel/traverse/lib/path/context.js:84:31)
    at TraversalContext.visitQueue (/Users/chsuh/decorators-bug/node_modules/@babel/traverse/lib/context.js:96:16)
    at TraversalContext.visitMultiple (/Users/chsuh/decorators-bug/node_modules/@babel/traverse/lib/context.js:67:17)
    at TraversalContext.visit (/Users/chsuh/decorators-bug/node_modules/@babel/traverse/lib/context.js:119:19)
    at traverseNode (/Users/chsuh/decorators-bug/node_modules/@babel/traverse/lib/traverse-node.js:18:17)
    at NodePath.visit (/Users/chsuh/decorators-bug/node_modules/@babel/traverse/lib/path/context.js:90:52) {
  code: 'BABEL_TRANSFORM_ERROR'
}

Environment

System:
OS: macOS 13.1
Binaries:
Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node
npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm
npmPackages:
@babel/cli: ^7.19.3 => 7.19.3
@babel/plugin-proposal-decorators: ^7.20.5 => 7.20.5
@babel/plugin-transform-block-scoping: ^7.20.5 => 7.20.5

Possible solution

No response

Additional context

No response

@babel-bot
Copy link
Collaborator

Hey @charlessuh! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

@charlessuh charlessuh changed the title [Bug]: Cannot set properties of undefined (setting 'identifier') error when using plugin-proposal-decorators with plugin-transform-block-scoping [Bug]: Cannot set properties of undefined (setting 'identifier') error when using plugin-proposal-decorators legacy with plugin-transform-block-scoping Dec 22, 2022
@charlessuh
Copy link
Contributor Author

@liuxingbaoyu
Copy link
Member

I can reproduce it with the latest release, but not in the main branch, not sure if it's because of #15200.

@nicolo-ribaudo
Copy link
Member

Lets try releasing and see if it fixes the bug then :)

@liuxingbaoyu
Copy link
Member

After the update the problem disappeared.馃槀

@nicolo-ribaudo
Copy link
Member

@charlessuh Can you confirm that updating all your Babel dependencies fixed this for you?

@cjones26
Copy link

cjones26 commented Dec 22, 2022

It may not be fully related, but we are seeing something similar here: storybookjs/storybook#20382.

We were able to resolve by reverting to an older version of @babel/plugin-transform-block-scoping@7.18.9.

@liuxingbaoyu
Copy link
Member

@cjones26 #15299 Can you try v7.20.8?

@cjones26
Copy link

@liuxingbaoyu I just tried v7.20.8 with no luck, but v7.20.5 does in fact work properly.

@liuxingbaoyu
Copy link
Member

@cjones26 v7.20.9 has been released, has the problem been solved?

@necatisarhanli
Copy link

@liuxingbaoyu I don't see the new release (v7.20.9) on npm , where can we find it?

@liuxingbaoyu
Copy link
Member

@eductech
Copy link

Hello. We use 3rd party bundling tool that has depth "@babel/preset-env": "^7.11.5". Now it installs @babel/plugin-transform-block-scoping@7.20.7 which seems to be corrupted by the issue raised and build fails. How we can resolve this?

@nicolo-ribaudo
Copy link
Member

Delete @babel/plugin-transform-block-scoping from your lockfile and reinstall your dependencies

@eductech
Copy link

eductech commented Dec 23, 2022

@nicolo-ribaudo thanks. With @babel/plugin-transform-block-scoping@7.20.9 issue was resolved in our case

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Mar 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

7 participants