@@ -874,10 +874,16 @@ class WebpackCLI {
874874 }
875875
876876 command . addOption ( optionForCommand ) ;
877- }
877+ } else if ( mainOption . type . size === 0 && negativeOption ) {
878+ const optionForCommand = new Option ( mainOption . flags , mainOption . description ) ;
879+
880+ // Hide stub option
881+ optionForCommand . flags = "" ;
882+ optionForCommand . hidden = option . hidden || true ;
883+ ( optionForCommand as Option & { internal ?: boolean } ) . internal = true ;
878884
879- // A situation arises when `mainOption.type.size === 0 && negativeOption`
880- // In this case, we don't create the option, since this means the option only has a negative value
885+ command . addOption ( optionForCommand ) ;
886+ }
881887
882888 if ( negativeOption ) {
883889 const optionForCommand = new Option ( negativeOption . flags , negativeOption . description ) . default (
@@ -1043,6 +1049,10 @@ class WebpackCLI {
10431049 } ,
10441050 visibleOptions : function visibleOptions ( command ) {
10451051 return command . options . filter ( ( option ) => {
1052+ if ( ( option as Option & { internal ?: boolean } ) . internal ) {
1053+ return false ;
1054+ }
1055+
10461056 // Hide `--watch` option when developer use `webpack watch --help`
10471057 if (
10481058 ( options [ 0 ] === "w" || options [ 0 ] === "watch" ) &&
@@ -1977,7 +1987,10 @@ class WebpackCLI {
19771987 }
19781988
19791989 for ( const option of command . options ) {
1980- if ( distance ( name , option . long ?. slice ( 2 ) as string ) < 3 ) {
1990+ if (
1991+ ! ( option as Option & { internal ?: boolean } ) . internal &&
1992+ distance ( name , option . long ?. slice ( 2 ) as string ) < 3
1993+ ) {
19811994 this . logger . error ( `Did you mean '--${ option . name ( ) } '?` ) ;
19821995 }
19831996 }
0 commit comments