Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit b6d60b2

Browse files
committed
fix: remove 'as any' type casts in retention feature
- Import and use RetentionSetting type instead of 'as any' in extension.ts - Use proper type narrowing for metadata parsing instead of 'as any'
1 parent 943186a commit b6d60b2

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import {
4545
} from "./activate"
4646
import { initializeI18n } from "./i18n"
4747
import { flushModels, initializeModelCacheRefresh, refreshModels } from "./api/providers/fetchers/modelCache"
48-
import { purgeOldTasks } from "./utils/task-history-retention"
48+
import { purgeOldTasks, RetentionSetting } from "./utils/task-history-retention"
4949

5050
/**
5151
* Built using https://github.com/microsoft/vscode-webview-ui-toolkit
@@ -130,7 +130,7 @@ export async function activate(context: vscode.ExtensionContext) {
130130
outputChannel.appendLine(`[Retention] Startup purge: setting=${retention}`)
131131

132132
const result = await purgeOldTasks(
133-
retention as any,
133+
retention as RetentionSetting,
134134
contextProxy.globalStorageUri.fsPath,
135135
(m) => {
136136
outputChannel.appendLine(m)

src/utils/task-history-retention.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,10 @@ export async function purgeOldTasks(
153153
// First try to get a timestamp from task_metadata.json (if present)
154154
try {
155155
const raw = await fs.readFile(metadataPath, "utf8")
156-
const meta = JSON.parse(raw)
157-
const maybeTs = Number((meta as any)?.ts)
156+
const meta: unknown = JSON.parse(raw)
157+
const maybeTs = Number(
158+
typeof meta === "object" && meta !== null && "ts" in meta ? (meta as { ts: unknown }).ts : undefined,
159+
)
158160
if (Number.isFinite(maybeTs)) {
159161
ts = maybeTs
160162
}

0 commit comments

Comments
 (0)