@@ -122,15 +122,28 @@ export class BaseGenerator<
122122 * }
123123 * };
124124 */
125- constructor ( options : O , features ?: F ) ;
126- constructor ( args : string [ ] , options : O , features ?: F ) ;
127-
128- constructor ( args : string [ ] | O , options : O | F , features ?: F ) {
125+ constructor ( args ?: string [ ] , options ?: O , features ?: F ) ;
126+ constructor ( args ?: string | string [ ] | O , options ?: O | F , features ?: F ) {
129127 super ( ) ;
130128
131- const actualArgs : string [ ] = Array . isArray ( args ) ? args : [ ] ;
132- const actualOptions = Array . isArray ( args ) ? ( options as O ) : args ;
133- const actualFeatures = Array . isArray ( args ) ? features : ( options as F ) ;
129+ args = typeof args === 'string' ? [ args ] : args ;
130+
131+ // Handle backward Compatibility
132+ let actualArgs : string [ ] ;
133+ let actualOptions : O ;
134+ let actualFeatures : F | undefined ;
135+ if ( typeof features === 'object' ) {
136+ actualArgs = args as string [ ] ;
137+ actualOptions = options as O ;
138+ actualFeatures = features ;
139+ } else if ( typeof args === 'object' && ! Array . isArray ( args ) ) {
140+ actualArgs = [ ] ;
141+ actualOptions = args as O ;
142+ } else {
143+ actualArgs = args ?? [ ] ;
144+ actualOptions = options as O ;
145+ }
146+
134147 const { env, ...generatorOptions } = actualOptions ;
135148
136149 // Load parameters
0 commit comments