fix(types): resolve zod v3 type inference differences in task tools

zod v3 infers .default([]) fields as string[] | undefined in z.infer
output type (unlike v4 which marks them as string[]). Add nullish
coalescing guards and use any[] for the readJsonSafe result array
to avoid the type mismatch in task-list and task-update.
This commit is contained in:
YeonGyu-Kim
2026-04-06 14:20:30 +09:00
parent 205269421d
commit 213cee27cc
2 changed files with 5 additions and 4 deletions
+3 -2
View File
@@ -37,7 +37,8 @@ Returns summary format: id, subject, status, owner, blockedBy (not full descript
return JSON.stringify({ tasks: [] })
}
const allTasks: TaskObject[] = []
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const allTasks: any[] = []
for (const fileId of files) {
const task = readJsonSafe(join(taskDir, `${fileId}.json`), TaskObjectSchema)
if (task) {
@@ -55,7 +56,7 @@ Returns summary format: id, subject, status, owner, blockedBy (not full descript
// Build summary with filtered blockedBy
const summaries: TaskSummary[] = activeTasks.map((task) => {
// Filter blockedBy to only include unresolved (non-completed) blockers
const unresolvedBlockers = task.blockedBy.filter((blockerId) => {
const unresolvedBlockers = (task.blockedBy ?? []).filter((blockerId: string) => {
const blockerTask = taskMap.get(blockerId)
// Include if blocker doesn't exist (missing) or if it's not completed
return !blockerTask || blockerTask.status !== "completed"
+2 -2
View File
@@ -114,12 +114,12 @@ async function handleUpdate(
const addBlocks = args.addBlocks as string[] | undefined;
if (addBlocks) {
task.blocks = [...new Set([...task.blocks, ...addBlocks])];
task.blocks = [...new Set([...(task.blocks ?? []), ...addBlocks])];
}
const addBlockedBy = args.addBlockedBy as string[] | undefined;
if (addBlockedBy) {
task.blockedBy = [...new Set([...task.blockedBy, ...addBlockedBy])];
task.blockedBy = [...new Set([...(task.blockedBy ?? []), ...addBlockedBy])];
}
if (validatedArgs.metadata !== undefined) {