Skip to content

Commit 587fcb3

Browse files
committed
Refactor isVersionInfo() to use json` module
1 parent 445107e commit 587fcb3

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/util.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -634,16 +634,16 @@ interface PersistedVersionInfo {
634634
}
635635

636636
function isVersionInfo(x: unknown): x is VersionInfo {
637-
const candidate = x as Partial<VersionInfo> | null;
638637
return (
639-
typeof candidate === "object" &&
640-
candidate !== null &&
641-
typeof candidate.version === "string" &&
642-
(candidate.features === undefined ||
643-
(typeof candidate.features === "object" &&
644-
candidate.features !== null)) &&
645-
(candidate.overlayVersion === undefined ||
646-
typeof candidate.overlayVersion === "number")
638+
json.isObject(x) &&
639+
json.validateSchema(
640+
{
641+
version: json.string,
642+
features: json.undefinable(json.object),
643+
overlayVersion: json.undefinable(json.number),
644+
},
645+
x,
646+
)
647647
);
648648
}
649649

0 commit comments

Comments
 (0)