From cccd23b6d26f83af3be6b3a8e8cfd81a4522d865 Mon Sep 17 00:00:00 2001 From: Attacktive Date: Mon, 23 May 2022 13:31:54 +0900 Subject: [PATCH] Avoid type coercion. --- src/utils/history.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils/history.ts b/src/utils/history.ts index a8f2420..0de2298 100644 --- a/src/utils/history.ts +++ b/src/utils/history.ts @@ -1,4 +1,4 @@ -type History = Record; +type History = Record; const history: History = {}; let historyIndex = 0; @@ -28,14 +28,15 @@ export function getCommandIfHistoryExpansion(input): string { if (index === '!') { command = getLast(); } else { - command = get(index); + // parseInt here is guaranteed to succeed I suppose. + command = get(parseInt(index)); } } return command; } -function get(index: string): string { +function get(index: number): string { return history[index]; }