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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polish: print friendly error when hoisting unsupported node types #390

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/regenerator-transform/src/hoist.js
Expand Up @@ -24,6 +24,10 @@ exports.hoist = function(funPath) {
let exprs = [];

vdec.declarations.forEach(function(dec) {
if (!t.isIdentifier(dec.id)) {
// We don't support ArrayPattern and ObjectPattern
throw new Error("Unsupported declarator with type " + JSON.stringify(dec.id.type) + ", please add \"@babel/plugin-transform-destructuring\" to your babel config.")
}
// Note: We duplicate 'dec.id' here to ensure that the variable declaration IDs don't
// have the same 'loc' value, since that can make sourcemaps and retainLines behave poorly.
vars[dec.id.name] = t.identifier(dec.id.name);
Expand Down