Skip to content

Commit

Permalink
chore(cli): prepare for noUncheckedIndexedAccess (denoland#4443)
Browse files Browse the repository at this point in the history
* chore(cli): prepare for `noUncheckedIndexedAccess`

* Update cli/parse_args.ts

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
  • Loading branch information
gabelluardo and iuioiua authored Mar 5, 2024
1 parent e1561a9 commit 6c7b13d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cli/parse_args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ function setNested(
object = object[key] as NestedMapping;
});

const key = keys[keys.length - 1];
const key = keys.at(-1)!;

if (collect) {
const v = object[key];
Expand Down Expand Up @@ -568,14 +568,14 @@ export function parseArgs<
}

for (let i = 0; i < args.length; i++) {
const arg = args[i];
const arg = args[i]!;

const groups = arg.match(FLAG_REGEXP)?.groups;

if (groups) {
const { doubleDash, negated } = groups;
let key = groups.key;
let value: string | number | boolean = groups.value;
let key = groups.key!;
let value: string | number | boolean | undefined = groups.value;

if (doubleDash) {
if (value) {
Expand Down Expand Up @@ -609,7 +609,7 @@ export function parseArgs<
continue;
}

if (isBooleanString(next)) {
if (next && isBooleanString(next)) {
value = parseBooleanString(next);
i++;
setArgument(key, value, arg, true);
Expand All @@ -632,7 +632,7 @@ export function parseArgs<
}

if (/[A-Za-z]/.test(letter) && /=/.test(next)) {
setArgument(letter, next.split(/=(.+)/)[1], arg, true);
setArgument(letter, next.split(/=(.+)/)[1]!, arg, true);
broken = true;
break;
}
Expand All @@ -646,7 +646,7 @@ export function parseArgs<
break;
}

if (letters[j + 1] && letters[j + 1].match(/\W/)) {
if (letters[j + 1] && letters[j + 1]!.match(/\W/)) {
setArgument(letter, arg.slice(j + 2), arg, true);
broken = true;
break;
Expand Down

0 comments on commit 6c7b13d

Please sign in to comment.