Skip to content

length property of function changes when declared async #4891

@damonmaria

Description

@damonmaria

Given the following I'd expect the same result from both lengths:

Input Code

const foo = (...args) => { }
console.log(foo.length)  // 0
const asyncFoo = async (...args) => { }
console.log(asyncFoo.length)  // 1

Babel Configuration (.babelrc, package.json, cli command)

.bablerc:

{
  "presets": [
    "react",
    "es2015",
    "stage-3"
  ],
  "plugins": [
    "transform-runtime",
    "transform-decorators-legacy",
    "transform-class-properties"
  ]
}

Package.json:

    "babel-core": "^6.18.2",
    "babel-plugin-transform-class-properties": "^6.18.0",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-plugin-transform-runtime": "^6.15.0",
    "babel-polyfill": "^6.16.0",
    "babel-preset-es2015": "^6.18.0",
    "babel-preset-react": "^6.16.0",
    "babel-preset-stage-3": "^6.17.0",

Context

I was tripped up because Mocha behaves differently depending on the test function's length. I couldn't figure out why everything stopped working when I changed a test wrapper function to async.

Your Environment

software version
Babel 6.18.2
node v4.6.2
npm 3.10.9
Operating System MacOS 10.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions