We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
isVersionInfo()
to use
1 parent 445107e commit 587fcb3Copy full SHA for 587fcb3
1 file changed
src/util.ts
@@ -634,16 +634,16 @@ interface PersistedVersionInfo {
634
}
635
636
function isVersionInfo(x: unknown): x is VersionInfo {
637
- const candidate = x as Partial<VersionInfo> | null;
638
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")
+ json.isObject(x) &&
+ json.validateSchema(
+ {
+ version: json.string,
+ features: json.undefinable(json.object),
+ overlayVersion: json.undefinable(json.number),
+ },
+ x,
+ )
647
);
648
649
0 commit comments