1-
21import chalk from "chalk" ;
32import * as logSymbols from "log-symbols" ;
43import * as Generator from "yeoman-generator" ;
@@ -11,7 +10,7 @@ import { Confirm, Input, List } from "@webpack-cli/webpack-scaffold";
1110import { WebpackOptions } from "./types" ;
1211import entryQuestions from "./utils/entry" ;
1312import langQuestionHandler from "./utils/language" ;
14- import styleQuestionHandler , { ILoader , StylingType } from "./utils/style" ;
13+ import styleQuestionHandler , { Loader , StylingType } from "./utils/style" ;
1514import tooltip from "./utils/tooltip" ;
1615
1716/**
@@ -55,8 +54,6 @@ export default class InitGenerator extends Generator {
5554 config : {
5655 configName : this . isProd ? "prod" : "config" ,
5756 topScope : [ ] ,
58- // TODO migrate tslint
59- // tslint:disable: object-literal-sort-keys
6057 webpackOptions : {
6158 mode : this . isProd ? "'production'" : "'development'" ,
6259 entry : undefined ,
@@ -66,7 +63,6 @@ export default class InitGenerator extends Generator {
6663 rules : [ ] ,
6764 } ,
6865 } ,
69- // tslint:enable: object-literal-sort-keys
7066 } ,
7167 } ;
7268
@@ -87,7 +83,7 @@ export default class InitGenerator extends Generator {
8783 ) ;
8884 }
8985
90- this . configuration . config . webpackOptions . plugins . push (
86+ ( this . configuration . config . webpackOptions . plugins as string [ ] ) . push (
9187 "new webpack.ProgressPlugin()" ,
9288 ) ;
9389
@@ -134,7 +130,7 @@ export default class InitGenerator extends Generator {
134130 const done : ( ) => { } = this . async ( ) ;
135131 const self : this = this ;
136132 let regExpForStyles : string ;
137- let ExtractUseProps : ILoader [ ] ;
133+ let ExtractUseProps : Loader [ ] ;
138134
139135 process . stdout . write (
140136 `\n${ logSymbols . info } ${ chalk . blue ( " INFO " ) } ` +
@@ -151,17 +147,17 @@ export default class InitGenerator extends Generator {
151147 ] )
152148 . then ( ( multiEntriesAnswer : {
153149 multiEntries : boolean ,
154- } ) =>
150+ } ) : Promise < { } > =>
155151 entryQuestions ( self , multiEntriesAnswer . multiEntries ) ,
156152 )
157- . then ( ( entryOption : object | string ) => {
153+ . then ( ( entryOption : object | string ) : void => {
158154 if ( typeof entryOption === "string" && entryOption . length > 0 ) {
159155 this . configuration . config . webpackOptions . entry = `${ entryOption } ` ;
160156 } else if ( typeof entryOption === "object" ) {
161157 this . configuration . config . webpackOptions . entry = entryOption ;
162158 }
163159 } )
164- . then ( ( ) =>
160+ . then ( ( ) : Promise < { } > =>
165161 this . prompt ( [
166162 Input (
167163 "outputDir" ,
@@ -172,7 +168,7 @@ export default class InitGenerator extends Generator {
172168 )
173169 . then ( ( outputDirAnswer : {
174170 outputDir : string ;
175- } ) => {
171+ } ) : void => {
176172 // As entry is not required anymore and we dont set it to be an empty string or """""
177173 // it can be undefined so falsy check is enough (vs entry.length);
178174 if (
@@ -193,7 +189,7 @@ export default class InitGenerator extends Generator {
193189 `path.resolve(__dirname, '${ outputDirAnswer . outputDir } ')` ;
194190 }
195191 } )
196- . then ( ( ) =>
192+ . then ( ( ) : Promise < { } > =>
197193 this . prompt ( [
198194 List ( "langType" , "Will you use one of the below JS solutions?" , [
199195 "ES6" ,
@@ -203,11 +199,11 @@ export default class InitGenerator extends Generator {
203199 ] ) ,
204200 )
205201 . then ( ( langTypeAnswer : {
206- langType : boolean ;
207- } ) => {
202+ langType : string ;
203+ } ) : void => {
208204 langQuestionHandler ( this , langTypeAnswer . langType ) ;
209205 } )
210- . then ( ( ) =>
206+ . then ( ( ) : Promise < { } > =>
211207 this . prompt ( [
212208 List ( "stylingType" , "Will you use one of the below CSS solutions?" , [
213209 "No" ,
@@ -219,10 +215,10 @@ export default class InitGenerator extends Generator {
219215 ] ) )
220216 . then ( ( stylingTypeAnswer : {
221217 stylingType : string ;
222- } ) =>
223- ( { ExtractUseProps, regExpForStyles } = styleQuestionHandler ( self , stylingTypeAnswer . stylingType ) ) ,
224- )
225- . then ( ( ) : Promise < Inquirer . Answers > => {
218+ } ) : void => {
219+ ( { ExtractUseProps, regExpForStyles } = styleQuestionHandler ( self , stylingTypeAnswer . stylingType ) ) ;
220+ } )
221+ . then ( ( ) : Promise < { } > | void => {
226222 if ( this . isProd ) {
227223 // Ask if the user wants to use extractPlugin
228224 return this . prompt ( [
@@ -235,7 +231,7 @@ export default class InitGenerator extends Generator {
235231 } )
236232 . then ( ( useExtractPluginAnswer : {
237233 useExtractPlugin : string ;
238- } ) => {
234+ } ) : void => {
239235 if ( regExpForStyles ) {
240236 if ( this . isProd ) {
241237 const cssBundleName : string = useExtractPluginAnswer . useExtractPlugin ;
@@ -246,12 +242,12 @@ export default class InitGenerator extends Generator {
246242 "\n" ,
247243 ) ;
248244 if ( cssBundleName . length !== 0 ) {
249- this . configuration . config . webpackOptions . plugins . push (
245+ ( this . configuration . config . webpackOptions . plugins as string [ ] ) . push (
250246 // TODO: use [contenthash] after it is supported
251247 `new MiniCssExtractPlugin({ filename:'${ cssBundleName } .[chunkhash].css' })` ,
252248 ) ;
253249 } else {
254- this . configuration . config . webpackOptions . plugins . push (
250+ ( this . configuration . config . webpackOptions . plugins as string [ ] ) . push (
255251 "new MiniCssExtractPlugin({ filename:'style.css' })" ,
256252 ) ;
257253 }
@@ -273,7 +269,7 @@ export default class InitGenerator extends Generator {
273269 } ) ;
274270 }
275271
276- public installPlugins ( ) {
272+ public installPlugins ( ) : void {
277273 const packager = getPackageManager ( ) ;
278274 const opts : {
279275 dev ?: boolean ,
@@ -292,7 +288,7 @@ export default class InitGenerator extends Generator {
292288 this . fs . extendJSON ( this . destinationPath ( "package.json" ) , require ( packageJsonTemplatePath ) ( this . isProd ) ) ;
293289
294290 const entry = this . configuration . config . webpackOptions . entry ;
295- const generateEntryFile = ( entryPath : string , name : string ) => {
291+ const generateEntryFile = ( entryPath : string , name : string ) : void => {
296292 entryPath = entryPath . replace ( / ' / g, "" ) ;
297293 this . fs . copyTpl (
298294 path . resolve ( __dirname , "./templates/index.js" ) ,
@@ -304,7 +300,7 @@ export default class InitGenerator extends Generator {
304300 if ( typeof entry === "string" ) {
305301 generateEntryFile ( entry , "your main file!" ) ;
306302 } else if ( typeof entry === "object" ) {
307- Object . keys ( entry ) . forEach ( ( name ) =>
303+ Object . keys ( entry ) . forEach ( ( name : string ) : void =>
308304 generateEntryFile ( entry [ name ] , `${ name } main file!` ) ,
309305 ) ;
310306 }
0 commit comments