Typecheck tests against current types

tsx runs tests without type checking and tsconfig.json covers only src,
so 71 type errors had accumulated unnoticed. tsconfig.tests.json now
checks every test and helper, and npm run typecheck includes it.

Fixtures gain the fields the DTOs have grown since they were written
(manualQuantity, circuit apparent power/cos phi, downstream board loads,
section totals, building, cover and board info fields). Repository
lookups that return "row ?? null" now declare the null in their type,
which their callers already handle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Julian Appel 2026-10-29 13:17:45 +01:00
parent a8cc7eca5e
commit 7222398628
37 changed files with 166 additions and 56 deletions

View file

@ -10,7 +10,7 @@ export class CircuitListRepository {
return db.select().from(circuitLists).where(eq(circuitLists.projectId, projectId));
}
async findById(projectId: string, circuitListId: string) {
async findById(projectId: string, circuitListId: string): Promise<typeof circuitLists.$inferSelect | null> {
const db = this.database;
const [row] = await db
.select()

View file

@ -15,7 +15,7 @@ export function createDefaultCircuitSectionValues(circuitListId: string) {
export class CircuitSectionRepository {
constructor(private readonly database: AppDatabase) {}
async findById(sectionId: string) {
async findById(sectionId: string): Promise<typeof circuitSections.$inferSelect | null> {
const db = this.database;
const [row] = await db.select().from(circuitSections).where(eq(circuitSections.id, sectionId)).limit(1);
return row ?? null;

View file

@ -53,7 +53,7 @@ export class GlobalDeviceRepository {
.where(eq(globalDevices.id, globalDeviceId));
}
async findById(globalDeviceId: string) {
async findById(globalDeviceId: string): Promise<typeof globalDevices.$inferSelect | null> {
const db = this.database;
const [row] = await db.select().from(globalDevices).where(eq(globalDevices.id, globalDeviceId)).limit(1);
return row ?? null;

View file

@ -41,7 +41,7 @@ export class ProjectRepository {
return project;
}
async findById(projectId: string) {
async findById(projectId: string): Promise<typeof projects.$inferSelect | null> {
const db = this.database;
const [row] = await db.select().from(projects).where(eq(projects.id, projectId)).limit(1);
return row ?? null;

View file

@ -32,13 +32,13 @@ export class UserRepository implements UserStore {
return rows.length;
}
async findById(userId: string) {
async findById(userId: string): Promise<typeof users.$inferSelect | null> {
const db = this.database;
const [row] = await db.select().from(users).where(eq(users.id, userId)).limit(1);
return row ?? null;
}
async findByUsername(username: string) {
async findByUsername(username: string): Promise<typeof users.$inferSelect | null> {
const db = this.database;
const [row] = await db
.select()