Skip to content

Commit

Permalink
fix: make key a requirement for option API
Browse files Browse the repository at this point in the history
  • Loading branch information
adbayb committed Mar 28, 2022
1 parent e7f023f commit e595089
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
18 changes: 6 additions & 12 deletions src/api/option/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,12 @@ export const createOption =

export type OptionParameters<
Values extends ObjectLikeConstraint,
Key
Key extends keyof Values
> = InstructionParameters<
Values,
Key extends keyof Values
? InstructionKey<Key> &
CommonParameters & {
defaultValue?: Values[Key];
}
: CommonParameters
InstructionKey<Key> & {
name: string | { long: string; short: string };
description: string;
defaultValue?: Values[Key];
}
>;

type CommonParameters = {
name: string | { long: string; short: string };
description: string;
};
4 changes: 3 additions & 1 deletion src/termost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export type Termost<Values extends ObjectLikeConstraint = EmptyObject> = {
input<Key extends keyof Values>(
params: InputParameters<Values, Key>
): Termost<Values>;
option<Key>(params: OptionParameters<Values, Key>): Termost<Values>;
option<Key extends keyof Values>(
params: OptionParameters<Values, Key>
): Termost<Values>;
task<Key>(params: TaskParameters<Values, Key>): Termost<Values>;
};

Expand Down

0 comments on commit e595089

Please sign in to comment.