leebyron/async-to-gen

TypeError: Cannot read property 'type' of null

albinekb opened this issue ยท 8 comments

I got this error, don't know why yet (checking and will update when i know what caused it)

.../node_modules/async-to-gen/index.js:451
if (node && typeof node === 'object' && (node.type || node.length && node[0].type)) {
                                                                                  ^
TypeError: Cannot read property 'type' of null

Probably a good idea to check if node[0].type exists and throw if it doesn't ๐Ÿ˜ฌ with a possible cause (once i've found out what caused this) ๐Ÿ’ญ

Here's the problem:

I was using this syntax (which is valid):

const string = 'Albin Ekblom'
const [, lastName] = string.split(' ')

Code to reproduce:

const getLastName = async function (string) {
  const [, lastName] = string.split(' ')
  return lastName
}

const run = async function () {
 const lastName = await getLastName('Albin Ekblom')
}

run()

Yikes, thanks for the report!

No probs ๐Ÿ˜„

Am I the only one using this syntax hehe? ๐Ÿ˜‚

I'll try to get it fixed and add a test-case for it later tonight ๐ŸŽ‰

I've got one coming, I'll unblock you :)

Amazing ๐ŸŽ‰
Thanks @leebyron

New version available on npm now, hopefully that works for you!

Confirmed, works ๐ŸŽ‰ thanks for fast fix!