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

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Apr 8, 2020

Context: babel/babel#10808

Transform the following snippet with only regenerator-transform

async (req) => {
  const { params } = req;
}

will throw

TypeError: /src.js: Property name expected type of string but got null
    at validate (/node_modules/@babel/types/lib/definitions/utils.js:164:13)
    at Object.validate (/node_modules/@babel/types/lib/definitions/utils.js:201:7)
    at validateField (node_modules/@babel/types/lib/validators/validate.js:22:9)
    at validate (/node_modules/@babel/types/lib/validators/validate.js:16:3)
    at builder (/node_modules/@babel/types/lib/builders/builder.js:38:27)
    at Object.Identifier (/node_modules/@babel/types/lib/builders/generated/index.js:334:31)
    at /node_modules/regenerator-transform/lib/hoist.js:32:29

Since practically every engine with native destructuring support will also have native generator support (thread). I think the value of pattern support is marginal. Hence we throw a better error.

@monsonjeremy
Copy link

🙌

@jeremytenjo
Copy link

jeremytenjo commented Apr 13, 2020

How is this error fixed?

I get the error with the following code

const hello = async () => {
  const he = { ll: '2' }
  const { ll } = he
}

More info here #391

Thanks @JLHwung

@monsonjeremy
Copy link

Any chance we can get this merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants