facebook / facebook/flow

module.name_mapper not working

未關閉
#1,068 34 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
bug
主要語言
Rust
星號
22.3k
分支
1.9k
PR 合併指標
30 天內沒有已合併 PR

描述

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?

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。