documentationjs / documentationjs/documentation

Flow type imports syntax is not enough to have module documented

Open
#680 7 comments 4 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
5.8k
Forks
481
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm trying to use `documentation.js` 4.0.0-beta.18 with `Flow` and it's working pretty well for infering types. However, my code is spread across several modules and I would like to use the [Flow type imports syntax](https://flowtype.org/docs/modules.html#type-imports--exports) like this:

```javascript
// index.js
// @flow
import type {MyNumber} from './types';

/**
* My number
*/
const myNumber: MyNumber = 1;
```

```javascript
// types.js
// @flow

/**
* My number type
*/
type MyNumber = number;

export type {
MyNumber
};
```

Here is the page generated by `documentation.js`:

![sad](https://cloud.githubusercontent.com/assets/6574550/23314562/c373ed44-fac2-11e6-886a-a19a8dfbea3e.png)

But instead I would expect:

![happy](https://cloud.githubusercontent.com/assets/6574550/23314602/f132a162-fac2-11e6-86eb-11cbc46d65d9.png)

Where `MyNumber` type is added to the documentation.

If I change `index.js` like this:

```diff
// @flow
+import './types';
import type {MyNumber} from './types';
```

Then I'll have the result of the second image.

So to me, it seems like an `import type` statement is not enough to have `documentation.js` look up the content of the imported module.

Can we add support for this `import type` syntax into `documentation.js` ? If yes, do you have an idea of where should I start if I wanted to change the actual behaviour and submit a PR ?

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.