TypeError: Cannot read property 'type' of null
albinekb opened this issue ยท 8 comments
albinekb commented
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) ๐ญ
albinekb commented
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()
leebyron commented
Yikes, thanks for the report!
albinekb commented
No probs ๐
Am I the only one using this syntax hehe? ๐
albinekb commented
I'll try to get it fixed and add a test-case for it later tonight ๐
leebyron commented
I've got one coming, I'll unblock you :)
leebyron commented
New version available on npm now, hopefully that works for you!
albinekb commented
Confirmed, works ๐ thanks for fast fix!