facebook / facebook/flow

module.name_mapper not working

Aperta
#1,068 34 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
Rust
Stelle
22.3k
Fork
1.9k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

I can't get module.name_mapper to work on the example in the documentation:
http://flowtype.org/docs/advanced-configuration.html#options

Flow version: 0.18.1

Folder structure:

```
.
├── interfaces/
│ └── ImageStub.js
├── .flowconfig
├── app.js
└── foo.jpg
```

Contents of `.flowconfig`:

```
[libs]
.*/interfaces/*

[options]
module.name_mapper='^image![a-zA-Z0-9$_]+$'->'ImageStub'
```

Contents of `ImageStub.js`:

```
declare module ImageStub {
declare var exports: { [key: string]: string };
}
```

Contents of `app.js`:

```
/* @flow */

require('image!foo.jpg');
```

Here is the output when doing `flow check`:

```
app.js:3
3: require('image!foo.jpg');
^^^^^^^^^^^^^^^^^^^^^^^^ image!foo.jpg. Required module not found

Found 1 error
```

To make sure that the regex pattern wasn't the problem I tried to dumb it down and just do the following:

Contents of `.flowconfig`:

```
[libs]
.*/interfaces/*

[options]
module.name_mapper='image'->'ImageStub'
```

Contents of `ImageStub.js`:

```
declare module ImageStub {
declare var exports: { [key: string]: string };
}
```

Contents of `app.js`:

```
/* @flow */

require('image');
```

and again, this is the output of `flow check`:

```
app.js:3
3: require('image');
^^^^^^^^^^^^^^^^ image. Required module not found

Found 1 error
```

Any ideas?

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.