From 2e4b62ef5853ed07c3db83c1133933d9f5117305 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Tue, 28 Apr 2026 20:40:12 -0300 Subject: [PATCH] fix: try to avoid could be instantiated with a different subtype of constraint issue Co-authored-by: Copilot --- src/generator.ts | 20 ++++++++++---------- src/index.ts | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/generator.ts b/src/generator.ts index cc072b71..a483eb5a 100644 --- a/src/generator.ts +++ b/src/generator.ts @@ -131,27 +131,27 @@ export class BaseGenerator< * } * }; */ - constructor(args?: string[], options?: O, features?: F); - constructor(args?: string | string[] | O, options?: O | F, features?: F) { + constructor(args?: string[], options?: BaseOptions, features?: BaseFeatures); + constructor(args?: string | string[] | BaseOptions, options?: BaseOptions | BaseFeatures, features?: BaseFeatures) { super(); args = typeof args === 'string' ? [args] : args; // Handle backward Compatibility let actualArgs: string[]; - let actualOptions: O; - let actualFeatures: F | undefined; + let actualOptions: BaseOptions; + let actualFeatures: BaseFeatures | undefined; if (typeof features === 'object') { actualArgs = args as string[]; - actualOptions = options as O; - actualFeatures = features; + actualOptions = options as BaseOptions; + actualFeatures = features as BaseFeatures; } else if (typeof args === 'object' && !Array.isArray(args)) { actualArgs = []; - actualOptions = args as O; - actualFeatures = options as F; + actualOptions = args as BaseOptions; + actualFeatures = options as BaseFeatures; } else { actualArgs = args ?? []; - actualOptions = options as O; + actualOptions = options as BaseOptions; } const { env, ...generatorOptions } = actualOptions; @@ -170,7 +170,7 @@ export class BaseGenerator< } // Parse parameters - this._initOptions = { ...actualOptions }; + this._initOptions = { ...actualOptions } as O; this._namespace = actualOptions.namespace; this._namespaceId = toNamespace(actualOptions.namespace); diff --git a/src/index.ts b/src/index.ts index faef7134..d98d9cb2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,7 +18,7 @@ export default class Generator< O extends BaseOptions = BaseOptions, F extends BaseFeatures = BaseFeatures, > extends BaseGenerator { - constructor(arguments_?: string[], options?: O, features?: F) { + constructor(arguments_?: string[], options?: BaseOptions, features?: BaseFeatures) { super(arguments_, options, features); // eslint-disable-next-line @typescript-eslint/ban-ts-comment