diff --git a/__tests__/__snapshots__/test.js.snap b/__tests__/__snapshots__/test.js.snap index 0ad23c1b9..b026bacc1 100644 --- a/__tests__/__snapshots__/test.js.snap +++ b/__tests__/__snapshots__/test.js.snap @@ -18930,6 +18930,185 @@ Object { } `; +exports[`outputs flow-exported-opaque-type.input.js JSON 1`] = ` +Array [ + Object { + "augments": Array [], + "context": Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 4, + }, + }, + }, + "description": Object { + "children": Array [ + Object { + "children": Array [ + Object { + "position": Object { + "end": Object { + "column": 30, + "line": 1, + "offset": 29, + }, + "indent": Array [], + "start": Object { + "column": 1, + "line": 1, + "offset": 0, + }, + }, + "type": "text", + "value": "MyOpaqueType Description Here", + }, + ], + "position": Object { + "end": Object { + "column": 30, + "line": 1, + "offset": 29, + }, + "indent": Array [], + "start": Object { + "column": 1, + "line": 1, + "offset": 0, + }, + }, + "type": "paragraph", + }, + ], + "position": Object { + "end": Object { + "column": 30, + "line": 1, + "offset": 29, + }, + "start": Object { + "column": 1, + "line": 1, + "offset": 0, + }, + }, + "type": "root", + }, + "errors": Array [], + "examples": Array [], + "implements": Array [], + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "members": Object { + "events": Array [], + "global": Array [], + "inner": Array [], + "instance": Array [], + "static": Array [], + }, + "name": "MyOpaqueType", + "namespace": "MyOpaqueType", + "params": Array [], + "path": Array [ + Object { + "name": "MyOpaqueType", + }, + ], + "properties": Array [], + "returns": Array [], + "sees": Array [], + "tags": Array [], + "throws": Array [], + "todos": Array [], + "yields": Array [], + }, +] +`; + +exports[`outputs flow-exported-opaque-type.input.js markdown 1`] = ` +" + +### Table of Contents + +- [MyOpaqueType][1] + +## MyOpaqueType + +MyOpaqueType Description Here + +[1]: #myopaquetype +" +`; + +exports[`outputs flow-exported-opaque-type.input.js markdown AST 1`] = ` +Object { + "children": Array [ + Object { + "type": "html", + "value": "", + }, + Object { + "children": Array [ + Object { + "type": "text", + "value": "MyOpaqueType", + }, + ], + "depth": 2, + "type": "heading", + }, + Object { + "children": Array [ + Object { + "position": Position { + "end": Object { + "column": 30, + "line": 1, + "offset": 29, + }, + "indent": Array [], + "start": Object { + "column": 1, + "line": 1, + "offset": 0, + }, + }, + "type": "text", + "value": "MyOpaqueType Description Here", + }, + ], + "position": Position { + "end": Object { + "column": 30, + "line": 1, + "offset": 29, + }, + "indent": Array [], + "start": Object { + "column": 1, + "line": 1, + "offset": 0, + }, + }, + "type": "paragraph", + }, + ], + "type": "root", +} +`; + exports[`outputs flow-optional-chaining.input.js JSON 1`] = ` Array [ Object { diff --git a/__tests__/fixture/flow-exported-opaque-type.input.js b/__tests__/fixture/flow-exported-opaque-type.input.js new file mode 100644 index 000000000..9bcf2e647 --- /dev/null +++ b/__tests__/fixture/flow-exported-opaque-type.input.js @@ -0,0 +1,4 @@ +// @flow + +/** MyOpaqueType Description Here */ +export opaque type MyOpaqueType: string = string \ No newline at end of file diff --git a/src/extractors/exported.js b/src/extractors/exported.js index 9a11323af..bd0191026 100644 --- a/src/extractors/exported.js +++ b/src/extractors/exported.js @@ -224,7 +224,8 @@ function findExportDeclaration( if ( declaration.isFunctionDeclaration() || declaration.isClassDeclaration() || - declaration.isTypeAlias() + declaration.isTypeAlias() || + declaration.isOpaqueType() ) { bindingName = declaration.node.id.name; } else if (declaration.isVariableDeclaration()) {