exporting a default async function is not defined

2019-02-24 09:02发布

问题:

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.

回答1:

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