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

Commit a80e98c

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 950480b commit a80e98c

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
@@ -44,7 +44,7 @@ import {
4444
} from "./activate"
4545
import { initializeI18n } from "./i18n"
4646
import { flushModels, initializeModelCacheRefresh, refreshModels } from "./api/providers/fetchers/modelCache"
47-
import { purgeOldTasks } from "./utils/task-history-retention"
47+
import { purgeOldTasks, RetentionSetting } from "./utils/task-history-retention"
4848

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

128128
const result = await purgeOldTasks(
129-
retention as any,
129+
retention as RetentionSetting,
130130
contextProxy.globalStorageUri.fsPath,
131131
(m) => {
132132
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)