Skip to content

Commit dda33e7

Browse files
committed
fix TS
1 parent e886d54 commit dda33e7

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

packages/hub/cli.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ import { typedEntries } from "./src/utils/typedEntries";
55
import { createBranch, uploadFilesWithProgress } from "./src";
66
import { pathToFileURL } from "node:url";
77

8+
// Didn't find the import from "node:util", so duplicated it here
9+
type OptionToken =
10+
| { kind: "option"; index: number; name: string; rawName: string; value: string; inlineValue: boolean }
11+
| {
12+
kind: "option";
13+
index: number;
14+
name: string;
15+
rawName: string;
16+
value: undefined;
17+
inlineValue: undefined;
18+
};
19+
820
const command = process.argv[2];
921
const args = process.argv.slice(3);
1022

@@ -242,12 +254,14 @@ function advParseArgs<C extends Command>(
242254
}
243255

244256
const positionals = Object.fromEntries(
245-
tokens.filter((token) => token.kind === "positional").map((token, i) => [expectedPositionals[i].name, token.value])
257+
tokens
258+
.filter((token): token is { kind: "positional"; index: number; value: string } => token.kind === "positional")
259+
.map((token, i) => [expectedPositionals[i].name, token.value])
246260
);
247261

248262
const options = Object.fromEntries(
249263
tokens
250-
.filter((token) => token.kind === "option")
264+
.filter((token): token is OptionToken => token.kind === "option")
251265
.map((token) => {
252266
const arg = command.args.find((arg) => arg.name === token.name || arg.short === token.name);
253267
if (!arg) {

0 commit comments

Comments
 (0)