is-async-function icon indicating copy to clipboard operation
is-async-function copied to clipboard

False positives for any function named "async" in classes or object literals

Open Melab opened this issue 3 years ago • 2 comments

isAsyncFunction will return true for both (class { async () {} }).prototype.async and { async () {} }.async. The cause is that keywords are allowed to be used as function/getter/setter names in classes and object literals, which the module is-async-function does not take into account.

Melab avatar Jun 11 '22 14:06 Melab

@melab

It's allowed but it's a bad practice, it's just a legacy pre async javascript.

Also, you may try parse-function, it uses full-fledged parsers, so there are no errors like this.


parseFunction(fn)

// result.isArrow
// result.isAsync
// result.isNamed
// result.isAnonymous
// result.isGenerator
// result.isExpression

tunnckoCore avatar Jun 18 '22 06:06 tunnckoCore

@Melab

It's allowed but it's a bad practice, it's just a legacy pre async javascript.

Also, you may try parse-function, it uses full-fledged parsers, so there are no errors like this.

parseFunction(fn)

// result.isArrow
// result.isAsync
// result.isNamed
// result.isAnonymous
// result.isGenerator
// result.isExpression

Of course it's allowed. I wouldn't have been able to test isAsyncFunction on it if it were invalid. I am just reporting this false positive to this project as a courtesy so that it may be fixed.

Melab avatar Jun 18 '22 20:06 Melab