fix: resolve all TypeScript errors in web app

This commit is contained in:
Jason Woltje
2026-01-29 22:23:28 -06:00
parent abbf886483
commit 1e927751a9
23 changed files with 207 additions and 136 deletions

View File

@@ -90,7 +90,7 @@ describe("GanttChart", () => {
render(<GanttChart tasks={tasks} />);
const taskRow = screen.getAllByText("Completed Task")[0].closest("[role='row']");
const taskRow = screen.getAllByText("Completed Task")[0]!.closest("[role='row']");
expect(taskRow?.className).toMatch(/Completed/i);
});
@@ -105,7 +105,7 @@ describe("GanttChart", () => {
render(<GanttChart tasks={tasks} />);
const taskRow = screen.getAllByText("Active Task")[0].closest("[role='row']");
const taskRow = screen.getAllByText("Active Task")[0]!.closest("[role='row']");
expect(taskRow?.className).toMatch(/InProgress/i);
});
});
@@ -219,8 +219,8 @@ describe("GanttChart", () => {
expect(bars).toHaveLength(2);
// Second bar should be wider (more days)
const bar1Width = bars[0].style.width;
const bar2Width = bars[1].style.width;
const bar1Width = bars[0]!.style.width;
const bar2Width = bars[1]!.style.width;
// Basic check that widths are set (exact values depend on implementation)
expect(bar1Width).toBeTruthy();

View File

@@ -34,8 +34,8 @@ function calculateTimelineRange(tasks: GanttTask[]): TimelineRange {
};
}
let earliest = tasks[0].startDate;
let latest = tasks[0].endDate;
let earliest = tasks[0]!.startDate;
let latest = tasks[0]!.endDate;
tasks.forEach((task) => {
if (task.startDate < earliest) {
@@ -65,7 +65,7 @@ function calculateBarPosition(
task: GanttTask,
timelineRange: TimelineRange,
rowIndex: number
): GanttBarPosition {
): Required<GanttBarPosition> {
const { start: rangeStart, totalDays } = timelineRange;
const taskStartOffset = Math.max(
@@ -81,11 +81,13 @@ function calculateBarPosition(
const leftPercent = (taskStartOffset / totalDays) * 100;
const widthPercent = (taskDuration / totalDays) * 100;
return {
const result: GanttBarPosition = {
left: `${leftPercent}%`,
width: `${widthPercent}%`,
top: rowIndex * 48, // 48px row height
};
return result;
}
/**
@@ -112,11 +114,11 @@ function getStatusClass(status: TaskStatus): string {
function getRowStatusClass(status: TaskStatus): string {
switch (status) {
case TaskStatus.COMPLETED:
return styles.rowCompleted;
return styles.rowCompleted || "";
case TaskStatus.IN_PROGRESS:
return styles.rowInProgress;
return styles.rowInProgress || "";
case TaskStatus.PAUSED:
return styles.rowPaused;
return styles.rowPaused || "";
default:
return "";
}
@@ -176,7 +178,7 @@ function calculateDependencyLines(
return;
}
const fromTask = tasks[fromIndex];
const fromTask = tasks[fromIndex]!;
// Calculate positions (as percentages)
const fromEndOffset = Math.max(

View File

@@ -201,8 +201,8 @@ describe("Gantt Types Helpers", () => {
const ganttTasks = toGanttTasks(tasks);
expect(ganttTasks).toHaveLength(2);
expect(ganttTasks[0].id).toBe("task-1");
expect(ganttTasks[1].id).toBe("task-2");
expect(ganttTasks[0]!.id).toBe("task-1");
expect(ganttTasks[1]!.id).toBe("task-2");
});
it("should filter out tasks that cannot be converted", () => {
@@ -240,9 +240,9 @@ describe("Gantt Types Helpers", () => {
const ganttTasks = toGanttTasks(tasks);
expect(ganttTasks[0].id).toBe("first");
expect(ganttTasks[1].id).toBe("second");
expect(ganttTasks[2].id).toBe("third");
expect(ganttTasks[0]!.id).toBe("first");
expect(ganttTasks[1]!.id).toBe("second");
expect(ganttTasks[2]!.id).toBe("third");
});
});
});

View File

@@ -96,13 +96,18 @@ export function toGanttTask(task: Task): GanttTask | null {
? metadataDependencies
: undefined;
return {
const ganttTask: GanttTask = {
...task,
startDate,
endDate,
dependencies,
isMilestone: task.metadata?.isMilestone === true,
};
if (dependencies) {
ganttTask.dependencies = dependencies;
}
return ganttTask;
}
/**