documentationjs / documentationjs/documentation

Flow type imports syntax is not enough to have module documented

Offen
#680 7 Kommentare 4 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
JavaScript
Sterne
5.8k
Forks
481
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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!

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Reproduziere das Problem mit den gezeigten index.js- und types.js-Beispielen unter Verwendung von documentation.js und untersuche anschließend, wie importierte Module und Flow-Typimporte behandelt werden. Bestätige die Verhaltensänderung, indem du prüfst, dass die generierte Dokumentation den Typ MyNumber enthält, ohne einen separaten Wertimport hinzuzufügen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript
Bereich
documentation
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
38/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.