Skip to content

Commit eb8bbf8

Browse files
univeriojohnnyreilly
authored andcommitted
Add a tip about suppressing "export not found" warnings for transpileOnly: true. (#751) (#753)
1 parent 4b7fc51 commit eb8bbf8

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,26 @@ different dependencies in your application will be lost.
214214

215215
It's advisable to use `transpileOnly` alongside the [fork-ts-checker-webpack-plugin](https://github.com/Realytics/fork-ts-checker-webpack-plugin) to get full type checking again. To see what this looks like in practice then either take a look at [our simple example](examples/fork-ts-checker). For a more complex setup take a look at our [more involved example](examples/react-babel-karma-gulp-fork-ts-checker).
216216

217+
If you enable this option, webpack 4 will give you "export not found" warnings any time you re-export a type:
218+
219+
```
220+
WARNING in ./src/bar.ts
221+
1:0-34 "export 'IFoo' was not found in './foo'
222+
@ ./src/bar.ts
223+
@ ./src/index.ts
224+
```
225+
226+
The reason this happens is that when typescript doesn't do a full type check, it does not have enough information to determine whether an imported name is a type or not, so when the name is then exported, typescript has no choice but to emit the export. Fortunately, the extraneous export should not be harmful, so you can just suppress these warnings:
227+
228+
```javascript
229+
module.exports = {
230+
...
231+
stats: {
232+
warningsFilter: /export .* was not found in/
233+
}
234+
}
235+
```
236+
217237
#### happyPackMode _(boolean) (default=false)_
218238

219239
If you're using [HappyPack](https://github.com/amireh/happypack) or [thread-loader](https://github.com/webpack-contrib/thread-loader) to parallise your builds then you'll need to set this to `true`. This implicitly sets `*transpileOnly*` to `true` and **WARNING!** stops registering **_all_** errors to webpack.

examples/fork-ts-checker/webpack.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ module.exports = {
2121
resolve: {
2222
extensions: [ '.ts', '.tsx', 'js' ]
2323
},
24+
stats: {
25+
// suppress "export not found" warnings about re-exported types
26+
warningsFilter: /export .* was not found in/
27+
},
2428
plugins: [
2529
new ForkTsCheckerWebpackPlugin()
2630
]

0 commit comments

Comments
 (0)