QuizNot attempted
Spot the bug: types that hide bugs
1–4 to choose, Enter to submit
Show answer & explanation
Correct answers:
- resourceData holds usage records but is typed as column definitions; res.json() returns any, so it is accepted
- The any index signature lets a cell be an object (a runtime crash) or a mixed type in the sort, with no error
- column.key is a plain string, so a typo in a column key compiles and renders an empty column
anyswitches checking off wherever it flows.- Type the record (`type Usage = { id: string
- cost: number
- date: string
- ... }
), make the table generic (Column<T> = { key: keyof T & string - label: string }
,Table<T>), and validate JSON at the boundary (a schema library or a type guard) soany` stops there. - Not required for dynamic data:
Record<string, unknown>compiles fine - you narrow a value before rendering it, which is exactly the check
anyskips.