diff --git a/src/loggingDatabaseOperations.ts b/src/loggingDatabaseOperations.ts index 3819711..003b1eb 100644 --- a/src/loggingDatabaseOperations.ts +++ b/src/loggingDatabaseOperations.ts @@ -33,7 +33,7 @@ export class LoggingDatabaseOperations implements DatabaseOperations { return this.wrapped.engineKind; } - private sanitizeValue(value: any): string { + private sanitizeValue(value: unknown): string { if (value === null) return 'null'; if (value === undefined) return 'undefined'; if (typeof value === 'string') { @@ -42,8 +42,8 @@ export class LoggingDatabaseOperations implements DatabaseOperations { } return `"${value}"`; } - if (value instanceof Uint8Array || (typeof value === 'object' && value && 'buffer' in value)) { - return `[BLOB ${value.byteLength} bytes]`; + if (value instanceof Uint8Array || (typeof value === 'object' && value !== null && 'buffer' in value)) { + return `[BLOB ${(value as { byteLength?: number }).byteLength ?? 0} bytes]`; } if (typeof value === 'object') { try { @@ -57,14 +57,15 @@ export class LoggingDatabaseOperations implements DatabaseOperations { // Constrain T to only callable (function) members of DatabaseOperations, // excluding non-function properties like `engineKind` (which is a Promise). - private async logAndDelegate any ? K : never }[keyof DatabaseOperations]>( + private async logAndDelegate unknown ? K : never }[keyof DatabaseOperations]>( message: string, isWrite: boolean, method: T, - ...args: Parameters any>> - ): Promise any>>> { + ...args: Parameters unknown>> + ): Promise unknown>>> { this.log(message, isWrite); - return (this.wrapped[method] as any)(...args); + const func = this.wrapped[method] as unknown as (...args: unknown[]) => unknown; + return func(...args) as ReturnType unknown>>; } private log(message: string, isWrite: boolean = false) {