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:
@@ -37,7 +37,8 @@ Returns summary format: id, subject, status, owner, blockedBy (not full descript
|
|||||||
return JSON.stringify({ tasks: [] })
|
return JSON.stringify({ tasks: [] })
|
||||||
}
|
}
|
||||||
|
|
||||||
const allTasks: TaskObject[] = []
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const allTasks: any[] = []
|
||||||
for (const fileId of files) {
|
for (const fileId of files) {
|
||||||
const task = readJsonSafe(join(taskDir, `${fileId}.json`), TaskObjectSchema)
|
const task = readJsonSafe(join(taskDir, `${fileId}.json`), TaskObjectSchema)
|
||||||
if (task) {
|
if (task) {
|
||||||
@@ -55,7 +56,7 @@ Returns summary format: id, subject, status, owner, blockedBy (not full descript
|
|||||||
// Build summary with filtered blockedBy
|
// Build summary with filtered blockedBy
|
||||||
const summaries: TaskSummary[] = activeTasks.map((task) => {
|
const summaries: TaskSummary[] = activeTasks.map((task) => {
|
||||||
// Filter blockedBy to only include unresolved (non-completed) blockers
|
// 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)
|
const blockerTask = taskMap.get(blockerId)
|
||||||
// Include if blocker doesn't exist (missing) or if it's not completed
|
// Include if blocker doesn't exist (missing) or if it's not completed
|
||||||
return !blockerTask || blockerTask.status !== "completed"
|
return !blockerTask || blockerTask.status !== "completed"
|
||||||
|
|||||||
@@ -114,12 +114,12 @@ async function handleUpdate(
|
|||||||
|
|
||||||
const addBlocks = args.addBlocks as string[] | undefined;
|
const addBlocks = args.addBlocks as string[] | undefined;
|
||||||
if (addBlocks) {
|
if (addBlocks) {
|
||||||
task.blocks = [...new Set([...task.blocks, ...addBlocks])];
|
task.blocks = [...new Set([...(task.blocks ?? []), ...addBlocks])];
|
||||||
}
|
}
|
||||||
|
|
||||||
const addBlockedBy = args.addBlockedBy as string[] | undefined;
|
const addBlockedBy = args.addBlockedBy as string[] | undefined;
|
||||||
if (addBlockedBy) {
|
if (addBlockedBy) {
|
||||||
task.blockedBy = [...new Set([...task.blockedBy, ...addBlockedBy])];
|
task.blockedBy = [...new Set([...(task.blockedBy ?? []), ...addBlockedBy])];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (validatedArgs.metadata !== undefined) {
|
if (validatedArgs.metadata !== undefined) {
|
||||||
|
|||||||
Reference in New Issue
Block a user