@@ -14,12 +14,20 @@ import { VersionInfo, versionInfoBaseSchema } from "./types";
1414export type CommandCacheKey = string ;
1515
1616/**
17- * The type of the command cache that is persisted to disk.
17+ * The JSON schema of the command cache that is persisted to disk.
1818 */
19- export interface OutputCache {
20- cmd : string ;
21- entries : Record < CommandCacheKey , unknown > ;
22- }
19+ const outputCacheSchema = {
20+ cmd : json . string ,
21+ entries : json . object ( { } ) ,
22+ } as const satisfies json . Schema ;
23+
24+ /**
25+ * The type that describes the command cache that is persisted to disk. This type
26+ * is partially derived from {@link outputCacheSchema}.
27+ */
28+ export type OutputCache = json . FromSchema < typeof outputCacheSchema > & {
29+ entries : { version : VersionInfo } ;
30+ } ;
2331
2432/**
2533 * The name of the temporary file that backs the on-disk cache of
@@ -138,13 +146,7 @@ function isVersionInfo(x: unknown): x is VersionInfo {
138146function isOutputCache ( x : unknown ) : x is OutputCache {
139147 return (
140148 json . isObject ( x ) &&
141- json . validateSchema (
142- {
143- cmd : json . string ,
144- entries : json . object ( { } ) ,
145- } as const satisfies json . Schema ,
146- x ,
147- ) &&
149+ json . validateSchema ( outputCacheSchema , x ) &&
148150 json . isObject < { version : unknown } > ( x . entries ) &&
149151 isVersionInfo ( x . entries . version )
150152 ) ;
0 commit comments