From 5c54e8926d793b389429fc7c8e57ee2563dcf13f Mon Sep 17 00:00:00 2001 From: Zwyx <29386932+Zwyx@users.noreply.github.com> Date: Wed, 8 Sep 2021 03:44:03 +0800 Subject: [PATCH] docs: improve typing of Difficulty in TypeScript example --- docs/typescript.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/typescript.md b/docs/typescript.md index ecc9d4fd6..9c2eb71a2 100644 --- a/docs/typescript.md +++ b/docs/typescript.md @@ -126,8 +126,8 @@ interface Arguments { To improve the `choices` option typing you can also specify its types: ```typescript -type Difficulty = 'normal' | 'nightmare' | 'hell'; -const difficulties: ReadonlyArray = ['normal', 'nightmare', 'hell']; +const difficulties = ["normal", "nightmare", "hell"] as const; +type Difficulty = typeof difficulties[number]; const argv = yargs.option('difficulty', { choices: difficulties,