diff --git a/__tests__/__snapshots__/test.js.snap b/__tests__/__snapshots__/test.js.snap index 9f4ff1567..d496a23b5 100644 --- a/__tests__/__snapshots__/test.js.snap +++ b/__tests__/__snapshots__/test.js.snap @@ -9823,6 +9823,7 @@ It takes a ", "todos": Array [], }, Object { + "async": true, "augments": Array [], "context": Object { "loc": Object { diff --git a/__tests__/lib/infer/kind.js b/__tests__/lib/infer/kind.js index 854bfc953..448e85354 100644 --- a/__tests__/lib/infer/kind.js +++ b/__tests__/lib/infer/kind.js @@ -82,13 +82,12 @@ test('inferKind', function() { ).kind ).toBe('function'); - expect( - inferKind( - toComment( - '/** Export default function */' + 'export default function foo() {}' - ) - ).kind - ).toBe('function'); + const asyncFunction = inferKind( + toComment('/** Async function */' + 'async function foo() {}') + ); + + expect(asyncFunction.kind).toBe('function'); + expect(asyncFunction.async).toBe(true); expect( inferKind(toComment('class Foo { /** set b */ set b(v) { } }')).kind @@ -106,6 +105,12 @@ test('inferKind', function() { 'function' ); + const asyncMethod = inferKind( + toComment('class Foo { /** b */ async b(v) { } }') + ); + expect(asyncMethod.kind).toBe('function'); + expect(asyncMethod.async).toBe(true); + expect( inferKind( toComment(function() { diff --git a/__tests__/lib/parse.js b/__tests__/lib/parse.js index 6853ba364..7ebfae7a8 100644 --- a/__tests__/lib/parse.js +++ b/__tests__/lib/parse.js @@ -72,6 +72,14 @@ test('parse - @arg', function() {}); test('parse - @argument', function() {}); +test('parse - @async', function() { + expect( + evaluate(function() { + /** @async */ + })[0].async + ).toBe(true); +}); + test('parse - @augments', function() { expect( evaluate(function() { diff --git a/src/infer/kind.js b/src/infer/kind.js index 0314ffd69..303ce1c3c 100644 --- a/src/infer/kind.js +++ b/src/infer/kind.js @@ -25,6 +25,9 @@ function inferKind(comment) { comment.kind = 'class'; } else { comment.kind = 'function'; + if (node.async) { + comment.async = true; + } } } else if (t.isTypeAlias(node)) { comment.kind = 'typedef'; diff --git a/src/parse.js b/src/parse.js index ae9f91e94..880a79558 100644 --- a/src/parse.js +++ b/src/parse.js @@ -23,6 +23,7 @@ const flatteners = { alias: flattenName, arg: synonym('param'), argument: synonym('param'), + async: flattenBoolean, /** * Parse tag * @private