@types/yargs
Advanced tools
Comparing version 17.0.13 to 17.0.14
@@ -838,3 +838,24 @@ // Type definitions for yargs 17.0 | ||
type InferredOptionType<O extends Options | PositionalOptions> = | ||
// Handle special cases first | ||
O extends ( | ||
| { coerce: (arg: any) => infer T } | ||
) ? IsRequiredOrHasDefault<O> extends true ? T : T | undefined : | ||
O extends ( | ||
| { type: "count"; default: infer D } | ||
| { count: true; default: infer D } | ||
) ? number | Exclude<D, undefined> : | ||
O extends ( | ||
| { type: "count" } | ||
| { count: true } | ||
) ? number : | ||
// Try to infer type with InferredOptionTypePrimitive | ||
IsUnknown<InferredOptionTypePrimitive<O>> extends false ? InferredOptionTypePrimitive<O> : | ||
// Use the type of `default` as the last resort | ||
O extends ( | ||
| { default: infer D } | ||
) ? Exclude<D, undefined> : unknown; | ||
// prettier-ignore | ||
type IsRequiredOrHasDefault<O extends Options | PositionalOptions> = | ||
O extends ( | ||
| { required: string | true } | ||
@@ -844,16 +865,21 @@ | { require: string | true } | ||
| { demandOption: string | true } | ||
) ? | ||
Exclude<InferredOptionTypeInner<O>, undefined> : | ||
InferredOptionTypeInner<O>; | ||
| { default: {} } | ||
) ? true : false; | ||
type IsAny<T> = 0 extends (1 & T) ? true : false; | ||
// prettier-ignore | ||
type InferredOptionTypeInner<O extends Options | PositionalOptions> = | ||
O extends { default: any, coerce: (arg: any) => infer T } ? T : | ||
O extends { default: infer D } ? D : | ||
O extends { type: "count" } ? number : | ||
O extends { count: true } ? number : | ||
RequiredOptionType<O> | undefined; | ||
type IsUnknown<T> = | ||
IsAny<T> extends true ? false : | ||
unknown extends T ? true : | ||
false; | ||
// prettier-ignore | ||
type RequiredOptionType<O extends Options | PositionalOptions> = | ||
type InferredOptionTypePrimitive<O extends Options | PositionalOptions> = | ||
O extends { default: infer D } ? InferredOptionTypeInner<O> | D : | ||
IsRequiredOrHasDefault<O> extends true ? InferredOptionTypeInner<O> : | ||
InferredOptionTypeInner<O> | undefined; | ||
// prettier-ignore | ||
type InferredOptionTypeInner<O extends Options | PositionalOptions> = | ||
O extends { choices: ReadonlyArray<infer C> } ? C : | ||
O extends { type: "array", string: true } ? string[] : | ||
@@ -876,4 +902,2 @@ O extends { type: "array", number: true } ? number[] : | ||
O extends { normalize: true } ? string : | ||
O extends { choices: ReadonlyArray<infer C> } ? C : | ||
O extends { coerce: (arg: any) => infer T } ? T : | ||
unknown; | ||
@@ -880,0 +904,0 @@ |
{ | ||
"name": "@types/yargs", | ||
"version": "17.0.13", | ||
"version": "17.0.14", | ||
"description": "TypeScript definitions for yargs", | ||
@@ -72,3 +72,3 @@ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/yargs", | ||
}, | ||
"typesPublisherContentHash": "9016ff10b6e6354147619595a33b71abde9faf7542f46ec8296d7c8d2bd5cc45", | ||
"typesPublisherContentHash": "55f48f27baf55e300b0d8d7b86e66b01ef28ff00687cfae2e99157d8286bdd62", | ||
"typeScriptVersion": "4.1", | ||
@@ -75,0 +75,0 @@ "exports": { |
@@ -11,3 +11,3 @@ # Installation | ||
### Additional Details | ||
* Last updated: Fri, 23 Sep 2022 23:33:10 GMT | ||
* Last updated: Wed, 23 Nov 2022 18:11:56 GMT | ||
* Dependencies: [@types/yargs-parser](https://npmjs.com/package/@types/yargs-parser) | ||
@@ -14,0 +14,0 @@ * Global values: none |
@@ -789,3 +789,24 @@ // The following TSLint rules have been disabled: | ||
type InferredOptionType<O extends Options | PositionalOptions> = | ||
// Handle special cases first | ||
O extends ( | ||
| { coerce: (arg: any) => infer T } | ||
) ? IsRequiredOrHasDefault<O> extends true ? T : T | undefined : | ||
O extends ( | ||
| { type: "count"; default: infer D } | ||
| { count: true; default: infer D } | ||
) ? number | Exclude<D, undefined> : | ||
O extends ( | ||
| { type: "count" } | ||
| { count: true } | ||
) ? number : | ||
// Try to infer type with InferredOptionTypePrimitive | ||
IsUnknown<InferredOptionTypePrimitive<O>> extends false ? InferredOptionTypePrimitive<O> : | ||
// Use the type of `default` as the last resort | ||
O extends ( | ||
| { default: infer D } | ||
) ? Exclude<D, undefined> : unknown; | ||
// prettier-ignore | ||
type IsRequiredOrHasDefault<O extends Options | PositionalOptions> = | ||
O extends ( | ||
| { required: string | true } | ||
@@ -795,16 +816,21 @@ | { require: string | true } | ||
| { demandOption: string | true } | ||
) ? | ||
Exclude<InferredOptionTypeInner<O>, undefined> : | ||
InferredOptionTypeInner<O>; | ||
| { default: {} } | ||
) ? true : false; | ||
type IsAny<T> = 0 extends (1 & T) ? true : false; | ||
// prettier-ignore | ||
type InferredOptionTypeInner<O extends Options | PositionalOptions> = | ||
O extends { default: any, coerce: (arg: any) => infer T } ? T : | ||
O extends { default: infer D } ? D : | ||
O extends { type: "count" } ? number : | ||
O extends { count: true } ? number : | ||
RequiredOptionType<O> | undefined; | ||
type IsUnknown<T> = | ||
IsAny<T> extends true ? false : | ||
unknown extends T ? true : | ||
false; | ||
// prettier-ignore | ||
type RequiredOptionType<O extends Options | PositionalOptions> = | ||
type InferredOptionTypePrimitive<O extends Options | PositionalOptions> = | ||
O extends { default: infer D } ? InferredOptionTypeInner<O> | D : | ||
IsRequiredOrHasDefault<O> extends true ? InferredOptionTypeInner<O> : | ||
InferredOptionTypeInner<O> | undefined; | ||
// prettier-ignore | ||
type InferredOptionTypeInner<O extends Options | PositionalOptions> = | ||
O extends { choices: ReadonlyArray<infer C> } ? C : | ||
O extends { type: "array", string: true } ? string[] : | ||
@@ -827,4 +853,2 @@ O extends { type: "array", number: true } ? number[] : | ||
O extends { normalize: true } ? string : | ||
O extends { choices: ReadonlyArray<infer C> } ? C : | ||
O extends { coerce: (arg: any) => infer T } ? T : | ||
unknown; | ||
@@ -831,0 +855,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
108947
1635