@@ -3,7 +3,7 @@ import * as webpack from 'webpack';
3
3
const supportedTypeScriptLoaders = [ 'ts-loader' , 'awesome-typescript-loader' ] ;
4
4
5
5
export function addReactHotModuleReplacementConfig ( webpackConfig : webpack . Configuration ) {
6
- const moduleConfig = webpackConfig . module as webpack . NewModule ;
6
+ const moduleConfig = webpackConfig . module as webpack . Module ;
7
7
const moduleRules = moduleConfig . rules ;
8
8
if ( ! moduleRules ) {
9
9
return ; // Unknown rules list format. Might be Webpack 1.x, which is not supported.
@@ -13,13 +13,13 @@ export function addReactHotModuleReplacementConfig(webpackConfig: webpack.Config
13
13
// to its array of loaders
14
14
for ( let ruleIndex = 0 ; ruleIndex < moduleRules . length ; ruleIndex ++ ) {
15
15
// We only support NewUseRule (i.e., { use: ... }) because OldUseRule doesn't accept array values
16
- const rule = moduleRules [ ruleIndex ] as webpack . NewUseRule ;
16
+ const rule = moduleRules [ ruleIndex ] as webpack . RuleSetRule ;
17
17
if ( ! rule . use ) {
18
18
continue ;
19
19
}
20
20
21
21
// We're looking for the first 'use' value that's a TypeScript loader
22
- const loadersArray = rule . use instanceof Array ? rule . use : [ rule . use ] ;
22
+ const loadersArray : webpack . RuleSetUseItem [ ] = rule . use instanceof Array ? rule . use : [ rule . use as webpack . RuleSetUseItem ] ;
23
23
const isTypescriptLoader = supportedTypeScriptLoaders . some ( typeScriptLoaderName => containsLoader ( loadersArray , typeScriptLoaderName ) ) ;
24
24
if ( ! isTypescriptLoader ) {
25
25
continue ;
@@ -43,11 +43,11 @@ export function addReactHotModuleReplacementConfig(webpackConfig: webpack.Config
43
43
} ) ;
44
44
}
45
45
46
- function containsLoader ( loadersArray : webpack . Loader [ ] , loaderName : string ) {
46
+ function containsLoader ( loadersArray : webpack . RuleSetUseItem [ ] , loaderName : string ) {
47
47
return loadersArray . some ( loader => {
48
48
// Allow 'use' values to be either { loader: 'name' } or 'name'
49
49
// No need to support legacy webpack.OldLoader
50
- const actualLoaderName = ( loader as webpack . NewLoader ) . loader || ( loader as string ) ;
50
+ const actualLoaderName = ( loader as webpack . RuleSetLoader ) . loader || ( loader as string ) ;
51
51
return actualLoaderName && new RegExp ( `\\b${ loaderName } \\b` ) . test ( actualLoaderName ) ;
52
52
} ) ;
53
53
}
0 commit comments