Skip to content

Commit

Permalink
fix(type): Set the exact Logger.create return type, closes #382
Browse files Browse the repository at this point in the history
  • Loading branch information
megahertz committed Dec 13, 2023
1 parent aa6161d commit c0610ec
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
15 changes: 15 additions & 0 deletions src/__specs__/index.d.main.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import defaultLog from '../../main';
import { ConsoleTransport, warn } from '../index';

// Default module export
defaultLog.warn('test');

// Check whether default logger is MainLogger
defaultLog.create({ logId: 'test '}).transports.file.level = 'error';

// CommonJS export
warn('test');

// Check named export
const transport: ConsoleTransport = defaultLog.transports.console
transport({ data: [], date: new Date(), level: 'info' })
11 changes: 11 additions & 0 deletions src/__specs__/index.d.renderer.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import defaultLog from '../../renderer';
import { warn } from '../index';

// Default module export
defaultLog.warn('test');

// CommonJS export
warn('test');

// Check global variable
__electronLog.info();
17 changes: 0 additions & 17 deletions src/__specs__/index.d.test.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ declare namespace Logger {
/**
* Create a new electron-log instance
*/
create(options: { logId: string }): Logger.Logger;
create(options: { logId: string }): this;

/**
* Low level method which logs the message using specified transports
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"noImplicitReturns": true
},
"include": [
"./src/__specs__/index.d.test.ts"
"./src/__specs__/index.d.*.ts",
]
}

0 comments on commit c0610ec

Please sign in to comment.