-
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
02c9761
commit 648f69c
Showing
25 changed files
with
386 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ node_modules | |
build | ||
yarn.lock | ||
test-d/build.ts | ||
.tsimp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
declare module 'minimist-options' { | ||
import type {Opts as MinimistOptions} from 'minimist'; | ||
|
||
export type {Opts as MinimistOptions} from 'minimist'; | ||
|
||
export type OptionType = 'string' | 'boolean' | 'number' | 'array' | 'string-array' | 'boolean-array' | 'number-array'; | ||
|
||
export type BaseOption< | ||
TypeOptionType extends OptionType, | ||
DefaultOptionType, | ||
> = { | ||
/** | ||
* The data type the option should be parsed to. | ||
*/ | ||
readonly type?: TypeOptionType; | ||
|
||
/** | ||
* An alias/list of aliases for the option. | ||
*/ | ||
readonly alias?: string | readonly string[]; | ||
|
||
/** | ||
* The default value for the option. | ||
*/ | ||
readonly default?: DefaultOptionType; | ||
}; | ||
|
||
export type StringOption = BaseOption<'string', string>; | ||
export type BooleanOption = BaseOption<'boolean', boolean>; | ||
export type NumberOption = BaseOption<'number', number>; | ||
export type DefaultArrayOption = BaseOption<'array', readonly string[]>; | ||
export type StringArrayOption = BaseOption<'string-array', readonly string[]>; | ||
export type BooleanArrayOption = BaseOption<'boolean-array', readonly boolean[]>; | ||
export type NumberArrayOption = BaseOption<'number-array', readonly number[]>; | ||
|
||
export type AnyOption = ( | ||
| StringOption | ||
| BooleanOption | ||
| NumberOption | ||
| DefaultArrayOption | ||
| StringArrayOption | ||
| BooleanArrayOption | ||
| NumberArrayOption | ||
); | ||
|
||
export type MinimistOption = Pick<MinimistOptions, 'stopEarly' | 'unknown' | '--'>; | ||
|
||
export type Options = MinimistOption & { | ||
[key: string]: ( | ||
| OptionType | ||
| StringOption | ||
| BooleanOption | ||
| NumberOption | ||
| DefaultArrayOption | ||
| StringArrayOption | ||
| BooleanArrayOption | ||
| NumberArrayOption | ||
); | ||
arguments?: string; | ||
}; | ||
|
||
/** | ||
* Write options for [minimist](https://npmjs.org/package/minimist) in a comfortable way. Support string, boolean, number and array options. | ||
*/ | ||
export default function buildOptions(options?: Options): MinimistOptions; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.