facebook / facebook/flow

module.name_mapper not working

Ouverte
#1,068 34 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
bug
Langage dominant
Rust
Étoiles
22.3k
Forks
1.9k
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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?

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.