@@ -3,7 +3,7 @@ import * as webpack from 'webpack';
33const supportedTypeScriptLoaders = [ 'ts-loader' , 'awesome-typescript-loader' ] ;
44
55export function addReactHotModuleReplacementConfig ( webpackConfig : webpack . Configuration ) {
6- const moduleConfig = webpackConfig . module as webpack . NewModule ;
6+ const moduleConfig = webpackConfig . module as webpack . Module ;
77 const moduleRules = moduleConfig . rules ;
88 if ( ! moduleRules ) {
99 return ; // Unknown rules list format. Might be Webpack 1.x, which is not supported.
@@ -13,13 +13,13 @@ export function addReactHotModuleReplacementConfig(webpackConfig: webpack.Config
1313 // to its array of loaders
1414 for ( let ruleIndex = 0 ; ruleIndex < moduleRules . length ; ruleIndex ++ ) {
1515 // 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 ;
1717 if ( ! rule . use ) {
1818 continue ;
1919 }
2020
2121 // 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 ] ;
2323 const isTypescriptLoader = supportedTypeScriptLoaders . some ( typeScriptLoaderName => containsLoader ( loadersArray , typeScriptLoaderName ) ) ;
2424 if ( ! isTypescriptLoader ) {
2525 continue ;
@@ -43,11 +43,11 @@ export function addReactHotModuleReplacementConfig(webpackConfig: webpack.Config
4343 } ) ;
4444}
4545
46- function containsLoader ( loadersArray : webpack . Loader [ ] , loaderName : string ) {
46+ function containsLoader ( loadersArray : webpack . RuleSetUseItem [ ] , loaderName : string ) {
4747 return loadersArray . some ( loader => {
4848 // Allow 'use' values to be either { loader: 'name' } or 'name'
4949 // 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 ) ;
5151 return actualLoaderName && new RegExp ( `\\b${ loaderName } \\b` ) . test ( actualLoaderName ) ;
5252 } ) ;
5353}
0 commit comments