mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-22 14:38:19 +02:00
fix(types): bring real code to zero TypeScript errors, fix three latent bugs
Continues the cleanup from 164 errors down to 88, all of which now sit in MemStorage — the in-memory dev mock — documented as known debt. Production server code and the entire client are at zero errors. Three genuine defects surfaced by the types and fixed: - deleteAnnouncement returned void while routes check the result and answer 404 "not found" on falsy: deleting an announcement succeeded in DB but the API reported failure on the fallback paths; it now returns a real boolean - AnnouncementMemoryStorage declared getAnnouncement twice; the first implementation was dead at runtime (second definition wins) and is removed - one route called storage.getDeliveryById(), a method that does not exist, crashing with a TypeError whenever hit; it now calls getDelivery() Everything else is type-level only (annotations, null-to-undefined for inline styles, honest signatures for markClientCalled's comment parameter and the invoice verification result's invoiceAmountTTC field), verified behavior-neutral: client build, production server bundle and the SMTP end-to-end test all pass unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FHdE9nEh8zHhQNGpCgrtYe
This commit is contained in:
19 files changed
+94
-101
No files matched your search
@@ -11,10 +11,10 @@ type AnnouncementWithRelations = DashboardMessageWithRelations;
|
||||
// Interface commune pour le stockage
|
||||
interface IAnnouncementStorage {
|
||||
getAnnouncements(groupIds?: number[]): Promise<AnnouncementWithRelations[]>;
|
||||
getAnnouncement(id: number): Promise<AnnouncementWithRelations | null>;
|
||||
getAnnouncement(id: number): Promise<AnnouncementWithRelations | null | undefined>;
|
||||
createAnnouncement(announcement: InsertAnnouncement): Promise<DashboardMessage>;
|
||||
updateAnnouncement(id: number, announcement: Partial<InsertAnnouncement>): Promise<DashboardMessage>;
|
||||
deleteAnnouncement(id: number): Promise<void>;
|
||||
deleteAnnouncement(id: number): Promise<boolean>;
|
||||
}
|
||||
|
||||
// Stockage PostgreSQL pour la production
|
||||
@@ -60,7 +60,7 @@ class AnnouncementDatabaseStorage implements IAnnouncementStorage {
|
||||
}));
|
||||
}
|
||||
|
||||
async getAnnouncement(id: number): Promise<AnnouncementWithRelations | null> {
|
||||
async getAnnouncement(id: number): Promise<AnnouncementWithRelations | null | undefined> {
|
||||
console.log('🔍 [DB] Getting single announcement:', id);
|
||||
|
||||
const result = await db
|
||||
@@ -136,10 +136,12 @@ class AnnouncementDatabaseStorage implements IAnnouncementStorage {
|
||||
return updated;
|
||||
}
|
||||
|
||||
async deleteAnnouncement(id: number): Promise<void> {
|
||||
await db
|
||||
async deleteAnnouncement(id: number): Promise<boolean> {
|
||||
const deleted = await db
|
||||
.delete(dashboardMessages)
|
||||
.where(eq(dashboardMessages.id, id));
|
||||
.where(eq(dashboardMessages.id, id))
|
||||
.returning({ id: dashboardMessages.id });
|
||||
return deleted.length > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,26 +186,6 @@ class AnnouncementMemoryStorage implements IAnnouncementStorage {
|
||||
this.announcements.set(testAnnouncement2.id, testAnnouncement2);
|
||||
}
|
||||
|
||||
async getAnnouncement(id: number): Promise<AnnouncementWithRelations | null> {
|
||||
const announcement = this.announcements.get(id);
|
||||
if (!announcement) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Ajouter les relations
|
||||
const users = await this.usersGetter();
|
||||
const groups = await this.groupsGetter();
|
||||
|
||||
const author = users.find(u => u.id === announcement.createdBy || u.username === announcement.createdBy);
|
||||
const group = announcement.storeId ? groups.find(g => g.id === announcement.storeId) : undefined;
|
||||
|
||||
return {
|
||||
...announcement,
|
||||
author: author || { id: announcement.createdBy, firstName: 'Utilisateur', lastName: 'Inconnu', username: announcement.createdBy } as User,
|
||||
group,
|
||||
};
|
||||
}
|
||||
|
||||
async getAnnouncements(groupIds?: number[]): Promise<AnnouncementWithRelations[]> {
|
||||
const announcements = Array.from(this.announcements.values());
|
||||
|
||||
@@ -329,12 +311,13 @@ class AnnouncementMemoryStorage implements IAnnouncementStorage {
|
||||
return announcementWithRelations;
|
||||
}
|
||||
|
||||
async deleteAnnouncement(id: number): Promise<void> {
|
||||
async deleteAnnouncement(id: number): Promise<boolean> {
|
||||
const deleted = this.announcements.delete(id);
|
||||
|
||||
|
||||
if (deleted) {
|
||||
console.log(`🗑️ Annonce supprimée: ID ${id} (${this.announcements.size}/${this.MAX_ANNOUNCEMENTS} restantes)`);
|
||||
}
|
||||
return deleted;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user