Skip to content

Commit 4ac35aa

Browse files
committed
Fix type errors
1 parent 8803db4 commit 4ac35aa

File tree

6 files changed

+26
-11
lines changed

6 files changed

+26
-11
lines changed

.github/workflows/code_checks.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,21 @@ jobs:
4343
with:
4444
python-version-file: ".python-version"
4545

46+
- name: "Set up Node.js"
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: '20'
50+
cache: 'npm'
51+
cache-dependency-path: 'dashboard/package-lock.json'
52+
4653
- name: Install the project
4754
run: uv sync --all-extras --dev
4855

56+
- name: Install dashboard dependencies
57+
run: |
58+
cd dashboard
59+
npm ci
60+
4961
- name: Install dependencies and check code
5062
run: |
5163
source .venv/bin/activate

dashboard/components/overview-table.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default function OverviewTable({ prSummaries }: OverviewTableProps) {
6767
className="w-full"
6868
>
6969
<option value="all">All Statuses</option>
70-
{filterOptions['status']?.map((status: string) => (
70+
{(filterOptions['status'] as string[] | undefined)?.map((status) => (
7171
<option key={status} value={status}>
7272
{status.replace('_', ' ')}
7373
</option>
@@ -85,7 +85,7 @@ export default function OverviewTable({ prSummaries }: OverviewTableProps) {
8585
className="w-full"
8686
>
8787
<option value="all">All Failure Types</option>
88-
{filterOptions['failure_type']?.map((type: string) => (
88+
{(filterOptions['failure_type'] as string[] | undefined)?.map((type) => (
8989
<option key={type} value={type}>
9090
{type}
9191
</option>

dashboard/components/pr-velocity-chart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export default function PRVelocityChart({ prSummaries }: PRVelocityChartProps) {
161161
</text>
162162
)
163163
}
164-
return null
164+
return <g />
165165
}}
166166
/>
167167
<YAxis

dashboard/lib/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function useTableData<T extends Record<string, unknown>>(
3333

3434
// Get unique values for each filter field
3535
const filterOptions = useMemo(() => {
36-
const options: Record<string, unknown[]> = {}
36+
const options: Record<string, T[keyof T][]> = {}
3737
filterFields.forEach(field => {
3838
options[field as string] = getUniqueValues(data, field)
3939
})

dashboard/lib/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export interface TraceIndex {
9898
}
9999

100100
// PR summary for overview table
101-
export interface PRSummary {
101+
export interface PRSummary extends Record<string, unknown> {
102102
repo: string
103103
pr_number: number
104104
title: string

dashboard/lib/utils.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,20 @@ export function sortBy<T>(
9595
direction: 'asc' | 'desc' = 'asc'
9696
): T[] {
9797
return [...array].sort((a, b) => {
98-
let aVal = a[field]
99-
let bVal = b[field]
98+
const aVal = a[field]
99+
const bVal = b[field]
100100

101101
// Handle null/undefined
102102
if (aVal == null) return 1
103103
if (bVal == null) return -1
104104

105105
// Handle dates
106106
if (aVal instanceof Date && bVal instanceof Date) {
107-
aVal = aVal.getTime() as number
108-
bVal = bVal.getTime() as number
107+
const aTime = aVal.getTime()
108+
const bTime = bVal.getTime()
109+
if (aTime < bTime) return direction === 'asc' ? -1 : 1
110+
if (aTime > bTime) return direction === 'asc' ? 1 : -1
111+
return 0
109112
}
110113

111114
if (aVal < bVal) return direction === 'asc' ? -1 : 1
@@ -136,9 +139,9 @@ export function searchFilter<T>(
136139
/**
137140
* Get unique values from array for a specific field
138141
*/
139-
export function getUniqueValues<T>(items: T[], field: keyof T): unknown[] {
142+
export function getUniqueValues<T, K extends keyof T>(items: T[], field: K): T[K][] {
140143
const uniqueSet = new Set(items.map(item => item[field]).filter(Boolean))
141-
return Array.from(uniqueSet)
144+
return Array.from(uniqueSet) as T[K][]
142145
}
143146

144147
/**

0 commit comments

Comments
 (0)