Avoid type coercion.

pull/11/head
Attacktive 3 years ago
parent 5d147beb30
commit cccd23b6d2

@ -1,4 +1,4 @@
type History = Record<string, string>; type History = Record<number, string>;
const history: History = {}; const history: History = {};
let historyIndex = 0; let historyIndex = 0;
@ -28,14 +28,15 @@ export function getCommandIfHistoryExpansion(input): string {
if (index === '!') { if (index === '!') {
command = getLast(); command = getLast();
} else { } else {
command = get(index); // parseInt here is guaranteed to succeed I suppose.
command = get(parseInt(index));
} }
} }
return command; return command;
} }
function get(index: string): string { function get(index: number): string {
return history[index]; return history[index];
} }

Loading…
Cancel
Save