Skip to content

Commit

Permalink
[PR] Add @flow mention in module
Browse files Browse the repository at this point in the history
Summary:
`flow` is mandatory in `export.js` files otherwise flow just do not report errors.
Closes facebook#4420

Differential Revision: D5501828

Pulled By: samwgoldman

fbshipit-source-id: ce7759fda6749b020047f2a546ae126da3058e20
  • Loading branch information
jdeniau authored and facebook-github-bot committed Jul 26, 2017
1 parent 7aac28e commit 1d2e572
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions website/en/docs/types/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ It is often useful to share types in between modules (files). In Flow, you can e
**`exports.js`**

```js
// @flow
export default class Foo {};
export type MyObject = { /* ... */ };
export interface MyInterface { /* ... */ };
Expand All @@ -16,9 +17,12 @@ export interface MyInterface { /* ... */ };
**`imports.js`**

```js
// @flow
import type Foo, {MyObject, MyInterface} from './exports';
```

> ***Don't forget to mention `@flow` on top of file, otherwise flow won't report error.***.
### Importing and exporting values <a class="toc" id="toc-importing-and-exporting-values" href="#toc-importing-and-exporting-values"></a>

Flow also supports importing the type of values exported by other modules using
Expand All @@ -27,6 +31,7 @@ Flow also supports importing the type of values exported by other modules using
**`exports.js`**

```js
// @flow
const myNumber = 42;
export default myNumber;
export class MyClass {
Expand All @@ -37,6 +42,7 @@ export class MyClass {
**`imports.js`**

```js
// @flow
import typeof myNumber from './exports';
import typeof {MyClass} from './exports';
```
Expand Down

0 comments on commit 1d2e572

Please sign in to comment.