Skip to content

Function: inferDefault()

ts
function 
inferDefault
(
type
): unknown;

Defined in: packages/parser/src/utils.ts:22

Infers the implicit default value for a flag type based on its type constructor. This is useful for help output to show the default values of types that have built-in defaults.

  • Boolean: false
  • [Boolean] (Counter): 0
  • [T] (Array): []
  • Object: {}
  • Others: undefined (no implicit default)

Parameters

ParameterTypeDescription

type

TypeValue

The type value (constructor or array of constructor)

Returns

unknown

The inferred default value, or undefined if no implicit default

Released under the MIT license