diff --git a/types/yargs/index.d.ts b/types/yargs/index.d.ts index 321fb3669b..fd933bc78c 100644 --- a/types/yargs/index.d.ts +++ b/types/yargs/index.d.ts @@ -370,7 +370,7 @@ declare namespace yargs { O extends { number: true } ? number : O extends { string: true } ? string : O extends { normalize: true } ? string : - O extends { choices: Array } ? C : + O extends { choices: ReadonlyArray } ? C : O extends { coerce: (arg: any) => infer T } ? T : any; @@ -389,7 +389,7 @@ declare namespace yargs { type SyncCompletionFunction = (current: string, argv: any) => string[]; type AsyncCompletionFunction = (current: string, argv: any, done: (completion: ReadonlyArray) => void) => void; type MiddlewareFunction = (args: Arguments) => void; - type Choices = Array; + type Choices = ReadonlyArray; type PositionalOptionsType = "boolean" | "number" | "string"; } diff --git a/types/yargs/yargs-tests.ts b/types/yargs/yargs-tests.ts index 78006d2c6e..3a580400c2 100644 --- a/types/yargs/yargs-tests.ts +++ b/types/yargs/yargs-tests.ts @@ -668,7 +668,7 @@ function Argv$scriptName() { } type Color = "red" | "blue" | "green"; -const colors: Color[] = ["red", "blue", "green"]; +const colors: ReadonlyArray = ["red", "blue", "green"]; function Argv$inferOptionTypes() { // $ExpectType { [x: string]: any; a: (string | number)[] | undefined; b: boolean | undefined; c: number; n: number | undefined; s: string | undefined; _: string[]; $0: string; }