Skip to content

Commit 213cee2

Browse files
committed
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.
1 parent 2052694 commit 213cee2

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/tools/task/task-list.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ Returns summary format: id, subject, status, owner, blockedBy (not full descript
3737
return JSON.stringify({ tasks: [] })
3838
}
3939

40-
const allTasks: TaskObject[] = []
40+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
41+
const allTasks: any[] = []
4142
for (const fileId of files) {
4243
const task = readJsonSafe(join(taskDir, `${fileId}.json`), TaskObjectSchema)
4344
if (task) {
@@ -55,7 +56,7 @@ Returns summary format: id, subject, status, owner, blockedBy (not full descript
5556
// Build summary with filtered blockedBy
5657
const summaries: TaskSummary[] = activeTasks.map((task) => {
5758
// Filter blockedBy to only include unresolved (non-completed) blockers
58-
const unresolvedBlockers = task.blockedBy.filter((blockerId) => {
59+
const unresolvedBlockers = (task.blockedBy ?? []).filter((blockerId: string) => {
5960
const blockerTask = taskMap.get(blockerId)
6061
// Include if blocker doesn't exist (missing) or if it's not completed
6162
return !blockerTask || blockerTask.status !== "completed"

src/tools/task/task-update.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ async function handleUpdate(
114114

115115
const addBlocks = args.addBlocks as string[] | undefined;
116116
if (addBlocks) {
117-
task.blocks = [...new Set([...task.blocks, ...addBlocks])];
117+
task.blocks = [...new Set([...(task.blocks ?? []), ...addBlocks])];
118118
}
119119

120120
const addBlockedBy = args.addBlockedBy as string[] | undefined;
121121
if (addBlockedBy) {
122-
task.blockedBy = [...new Set([...task.blockedBy, ...addBlockedBy])];
122+
task.blockedBy = [...new Set([...(task.blockedBy ?? []), ...addBlockedBy])];
123123
}
124124

125125
if (validatedArgs.metadata !== undefined) {

0 commit comments

Comments
 (0)