javascript - exporting a default async function is not defined in current file - Stack Overflow

The following works perfectly:export default function x () {return 'hello world'}export func

The following works perfectly:

export default function x () {
  return 'hello world'
}

export function y () {
  return x()
}

console.log(y())

However this does not work:

export default async function x () {
  return 'hello world'
}

export function y () {
  return x()
    .then(console.log)
}

y()

When the default function is async for some reason x is not defined.

The following works perfectly:

export default function x () {
  return 'hello world'
}

export function y () {
  return x()
}

console.log(y())

However this does not work:

export default async function x () {
  return 'hello world'
}

export function y () {
  return x()
    .then(console.log)
}

y()

When the default function is async for some reason x is not defined.

Share Improve this question edited Jan 23, 2017 at 1:04 loganfsmyth 162k31 gold badges346 silver badges258 bronze badges asked Dec 17, 2016 at 22:08 ThomasReggiThomasReggi 59.6k97 gold badges258 silver badges459 bronze badges 3
  • Do you need a polyfill of some kind for this? I remember some kind of babel polyfill solving something like this. Also what happens if you remove "default". – Tim Consolazio Commented Dec 17, 2016 at 22:12
  • 1 @TimConsolazio If I remove it, it works perfectly fine. – ThomasReggi Commented Dec 17, 2016 at 22:15
  • I'm using the babel latest plugin. – ThomasReggi Commented Dec 17, 2016 at 22:15
Add a ment  | 

1 Answer 1

Reset to default 4

Looks like this is a known issue inside babel project: https://github./babel/babel/issues/3786

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742302068a4418210.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信