@@ -9,25 +9,14 @@ import type { VersionInfo } from "./types";
99/**
1010 * The keys of the command cache. Each key corresponds to a command whose output we cache.
1111 */
12- export enum CommandCacheKey {
13- Version = "version" ,
14- }
15-
16- /**
17- * The mapping of CLI commands to the types of the output of each command that we cache.
18- */
19- export type CommandCacheKeyOutputMap = {
20- [ CommandCacheKey . Version ] : VersionInfo ;
21- } ;
12+ export type CommandCacheKey = string ;
2213
2314/**
2415 * The type of the command cache that is persisted to disk.
2516 */
26- export interface OutputCache < K extends CommandCacheKey > {
17+ export interface OutputCache {
2718 cmd : string ;
28- entries : {
29- [ P in K ] : CommandCacheKeyOutputMap [ K ] ;
30- } ;
19+ entries : Record < CommandCacheKey , unknown > ;
3120}
3221
3322/**
@@ -74,8 +63,8 @@ export function cacheCodeQlVersion(
7463 cachedCodeQlVersion = version ;
7564 const outputCache = {
7665 cmd,
77- entries : { [ CommandCacheKey . Version ] : version } ,
78- } satisfies OutputCache < CommandCacheKey . Version > ;
66+ entries : { version } ,
67+ } satisfies OutputCache ;
7968 // Persist the version so that subsequent Actions steps, which run in separate
8069 // processes, can reuse it rather than invoking `codeql version` again. We
8170 // record the CLI path so that a different step using a different CodeQL bundle
@@ -122,7 +111,7 @@ export function getCachedCodeQlVersion(
122111 }
123112 // Memoize the parsed value so that subsequent calls in this process don't
124113 // re-parse the environment variable.
125- cachedCodeQlVersion = persisted . entries [ CommandCacheKey . Version ] ;
114+ cachedCodeQlVersion = persisted . entries . version as VersionInfo ;
126115 return cachedCodeQlVersion ;
127116}
128117
@@ -148,13 +137,13 @@ function isVersionInfo(x: unknown): x is VersionInfo {
148137 * Determines whether a value is a `OutputCache` object.
149138 * @param x The value to test
150139 */
151- function isOutputCache ( x : unknown ) : x is OutputCache < CommandCacheKey . Version > {
152- const candidate = x as Partial < OutputCache < CommandCacheKey . Version > > | null ;
140+ function isOutputCache ( x : unknown ) : x is OutputCache {
141+ const candidate = x as Partial < OutputCache > | null ;
153142 return (
154143 typeof candidate === "object" &&
155144 candidate !== null &&
156145 typeof candidate . cmd === "string" &&
157146 candidate . entries !== undefined &&
158- isVersionInfo ( candidate . entries [ CommandCacheKey . Version ] )
147+ isVersionInfo ( candidate . entries . version )
159148 ) ;
160149}
0 commit comments