File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 5
5
/* eslint-disable @typescript-eslint/method-signature-style */
6
6
/* eslint-disable @typescript-eslint/no-explicit-any */
7
7
8
+ // This is a trick to encourage editor to suggest the known literals while still
9
+ // allowing any BaseType value.
10
+ // References:
11
+ // - https://github.com/microsoft/TypeScript/issues/29729
12
+ // - https://github.com/sindresorhus/type-fest/blob/main/source/literal-union.d.ts
13
+ // - https://github.com/sindresorhus/type-fest/blob/main/source/primitive.d.ts
14
+ type LiteralUnion < LiteralType , BaseType extends string | number > = LiteralType | ( BaseType & Record < never , never > ) ;
15
+
8
16
export class CommanderError extends Error {
9
17
code : string ;
10
18
exitCode : number ;
@@ -272,7 +280,8 @@ export interface OutputConfiguration {
272
280
273
281
export type AddHelpTextPosition = 'beforeAll' | 'before' | 'after' | 'afterAll' ;
274
282
export type HookEvent = 'preSubcommand' | 'preAction' | 'postAction' ;
275
- export type OptionValueSource = 'default' | 'config' | 'env' | 'cli' | 'implied' ;
283
+ // The source is a string so author can define their own too.
284
+ export type OptionValueSource = LiteralUnion < 'default' | 'config' | 'env' | 'cli' | 'implied' , string > | undefined ;
276
285
277
286
export type OptionValues = Record < string , any > ;
278
287
You can’t perform that action at this time.
0 commit comments