Skip to content

Commit

Permalink
fix: export constituent types of TypedCommandParameters individually
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Molisani <git@molisani.us>
  • Loading branch information
molisani authored and mkubilayk committed Oct 22, 2024
1 parent 52be948 commit 09dfb8d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
8 changes: 7 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ export {
UnsatisfiedPositionalError,
formatMessageForArgumentScannerError,
} from "./parameter/scanner";
export type { InputParser, TypedCommandParameters } from "./parameter/types";
export type {
Aliases,
InputParser,
TypedCommandFlagParameters,
TypedCommandParameters,
TypedCommandPositionalParameters,
} from "./parameter/types";
export { buildCommand } from "./routing/command/builder";
export type { CommandBuilderArguments } from "./routing/command/builder";
export type { Command } from "./routing/command/types";
Expand Down
18 changes: 9 additions & 9 deletions packages/core/src/parameter/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export type Aliases<T> = Readonly<Partial<Record<AvailableAlias, T>>>;

export type BaseFlags = Readonly<Record<string, unknown>>;

interface TypedCommandFlagParameters<FLAGS extends BaseFlags, CONTEXT extends CommandContext> {
interface TypedCommandFlagParameters_<FLAGS extends BaseFlags, CONTEXT extends CommandContext> {
/**
* Typed definitions for all flag parameters.
*/
Expand All @@ -72,21 +72,21 @@ interface TypedCommandFlagParameters<FLAGS extends BaseFlags, CONTEXT extends Co
readonly aliases?: Aliases<keyof FLAGS & string>;
}

type TypedCommandFlagParameters_<FLAGS extends BaseFlags, CONTEXT extends CommandContext> =
export type TypedCommandFlagParameters<FLAGS extends BaseFlags, CONTEXT extends CommandContext> =
Record<string, never> extends FLAGS
? Partial<TypedCommandFlagParameters<FLAGS, CONTEXT>>
: TypedCommandFlagParameters<FLAGS, CONTEXT>;
? Partial<TypedCommandFlagParameters_<FLAGS, CONTEXT>>
: TypedCommandFlagParameters_<FLAGS, CONTEXT>;

interface TypedCommandPositionalParameters<ARGS extends BaseArgs, CONTEXT extends CommandContext> {
interface TypedCommandPositionalParameters_<ARGS extends BaseArgs, CONTEXT extends CommandContext> {
/**
* Typed definitions for all positional parameters.
*/
readonly positional: TypedPositionalParameters<ARGS, CONTEXT>;
}

type TypedCommandPositionalParameters_<ARGS extends BaseArgs, CONTEXT extends CommandContext> = [] extends ARGS
? Partial<TypedCommandPositionalParameters<ARGS, CONTEXT>>
: TypedCommandPositionalParameters<ARGS, CONTEXT>;
export type TypedCommandPositionalParameters<ARGS extends BaseArgs, CONTEXT extends CommandContext> = [] extends ARGS
? Partial<TypedCommandPositionalParameters_<ARGS, CONTEXT>>
: TypedCommandPositionalParameters_<ARGS, CONTEXT>;

/**
* Definitions for all parameters requested by the corresponding command.
Expand All @@ -95,7 +95,7 @@ export type TypedCommandParameters<
FLAGS extends BaseFlags,
ARGS extends BaseArgs,
CONTEXT extends CommandContext,
> = TypedCommandFlagParameters_<FLAGS, CONTEXT> & TypedCommandPositionalParameters_<ARGS, CONTEXT>;
> = TypedCommandFlagParameters<FLAGS, CONTEXT> & TypedCommandPositionalParameters<ARGS, CONTEXT>;

/**
* Definitions for all parameters requested by the corresponding command.
Expand Down

0 comments on commit 09dfb8d

Please sign in to comment.