From eb769a40abc07fe8fb5ec54d9aef0634dd808a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Viken=20Valv=C3=A5g?= Date: Mon, 3 Dec 2018 00:05:18 +0100 Subject: [PATCH] Use ReadonlyArray for choices. --- types/yargs/index.d.ts | 4 ++-- types/yargs/yargs-tests.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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; }