Skip to content

Commit 7a33626

Browse files
committed
fix: resolve all TS compiling errs
1 parent 84c298a commit 7a33626

4 files changed

Lines changed: 34 additions & 21 deletions

File tree

src/compatibility/loggers/BaseCompatibleLogger.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ export abstract class BaseCompatibleLogger {
257257
*/
258258
private getCircularReplacer(): (key: string, value: any) => any {
259259
const seen = new WeakSet();
260-
return (key: string, value: any) => {
260+
return (_key: string, value: any) => {
261261
if (typeof value === 'object' && value !== null) {
262262
if (seen.has(value)) {
263263
return '[Circular]';
@@ -288,18 +288,27 @@ export abstract class BaseCompatibleLogger {
288288
// Fall through to plain format on error
289289
}
290290
}
291-
// Fall through to plain if no formatter or error
291+
// If no formatter or formatter failed, use plain format
292+
return this.formatAsPlain(entry);
292293

293294
case 'plain':
294295
default:
295-
if (typeof entry === 'string') {
296-
return entry;
297-
}
298-
if (typeof entry === 'object' && entry.message) {
299-
return entry.message;
300-
}
301-
return this.safeSerialize(entry);
296+
return this.formatAsPlain(entry);
297+
}
298+
}
299+
300+
/**
301+
* Format entry as plain text.
302+
* @private
303+
*/
304+
private formatAsPlain(entry: unknown): string {
305+
if (typeof entry === 'string') {
306+
return entry;
307+
}
308+
if (typeof entry === 'object' && entry && 'message' in entry) {
309+
return String((entry as { message: unknown }).message);
302310
}
311+
return this.safeSerialize(entry);
303312
}
304313

305314
/**

src/compatibility/loggers/BunyanCompatibleLogger.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,11 +410,14 @@ export class BunyanCompatibleLogger extends BaseCompatibleLogger {
410410

411411
const match = line.match(/at\s+(?:(.+?)\s+)?\((.+?):(\d+):(\d+)\)/);
412412
if (match) {
413-
return {
414-
file: match[2] || 'unknown',
415-
line: parseInt(match[3], 10),
416-
func: match[1] || undefined,
413+
const result: BunyanRecord['src'] = {
414+
file: match[2] ? match[2] : 'unknown',
415+
line: parseInt(match[3] || '0', 10),
417416
};
417+
if (match[1]) {
418+
result.func = match[1].trim();
419+
}
420+
return result;
418421
}
419422
}
420423

src/compatibility/loggers/PinoCompatibleLogger.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ export class PinoCompatibleLogger extends BaseCompatibleLogger {
423423

424424
const [current, ...rest] = pathParts;
425425

426+
// Check if current path part exists
427+
if (!current) return;
428+
426429
// Handle wildcards
427430
if (current === '*') {
428431
if (Array.isArray(obj)) {
@@ -444,7 +447,7 @@ export class PinoCompatibleLogger extends BaseCompatibleLogger {
444447

445448
// Handle array notation
446449
const arrayMatch = current.match(/^(.+)\[\*\]$/);
447-
if (arrayMatch) {
450+
if (arrayMatch && arrayMatch[1]) {
448451
const arrayKey = arrayMatch[1];
449452
if (arrayKey in obj && Array.isArray(obj[arrayKey])) {
450453
const arr = obj[arrayKey] as unknown[];

src/transports/base/TransportManager.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,6 @@ export class TransportManager extends EventEmitter {
133133
*/
134134
private readonly stopOnSuccess: boolean;
135135

136-
/**
137-
* Default timeout for transport operations.
138-
* @private
139-
*/
140-
private readonly defaultTimeout?: number;
141-
142136
/**
143137
* Global error handler for transport errors.
144138
* @private
@@ -197,7 +191,6 @@ export class TransportManager extends EventEmitter {
197191
this.maxPauseQueueSize = options.maxPauseQueueSize || 10000;
198192
this.healthCheckIntervalMs = options.healthCheckIntervalMs || 60000;
199193
this.stopOnSuccess = options.stopOnSuccess || false;
200-
this.defaultTimeout = options.defaultTimeout;
201194
this.errorHandler = options.errorHandler;
202195

203196
// Set max listeners for better event handling
@@ -641,6 +634,11 @@ export class TransportManager extends EventEmitter {
641634

642635
results.forEach((result, index) => {
643636
const transport = availableTransports[index];
637+
if (!transport) {
638+
// Skip if transport is undefined (shouldn't happen but handle gracefully)
639+
return;
640+
}
641+
644642
if (result.status === 'fulfilled') {
645643
successfulTransports.push(transport.name);
646644
} else {

0 commit comments

Comments
 (0)