Skip to content

Commit

Permalink
fix typings and simlify booleanify
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed May 17, 2024
1 parent 6f6877c commit a6ca1cb
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/babel-cli/src/babel/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,18 +364,15 @@ export default function parseArgv(args: Array<string>): CmdOptions | null {
};
}

function booleanify(val: "false" | 0 | ""): false;
function booleanify(val: "true" | 1): true;
function booleanify(val: any): any {
if (val === undefined) return undefined;

// eslint-disable-next-line eqeqeq
if (val === "true" || val == 1) {
function booleanify(val: "false" | "0" | ""): false;
function booleanify(val: "true" | "1"): true;
function booleanify(val: string): boolean | string {
if (val === "true" || val === "1") {
return true;
}

// eslint-disable-next-line eqeqeq
if (val === "false" || val == 0 || !val) {
// false for --opt=false; 0 for --opt=0 or --opt 0; "" for --opt=
if (val === "false" || val === "0" || val === "") {
return false;
}

Expand Down

0 comments on commit a6ca1cb

Please sign in to comment.