I'm having a hard time trying to get a winstom custom logger compiled using typescript.
I'm taking this js code as starting point and taking into account this comment from github:
import * as Transport from 'winston-transport'
//
// Inherit from `winston-transport` so you can take advantage
// of the base functionality and `.exceptions.handle()`.
//
module.exports = class YourCustomTransport extends Transport {
constructor(opts) {
super(opts);
//
// Consume any custom options here. e.g.:
// - Connection information for databases
// - Authentication information for APIs (e.g. loggly, papertrail,
// logentries, etc.).
//
}
log(info, callback) {
setImmediate(() => {
this.emit('logged', info);
});
// Perform the writing to the remote service
callback();
}
};
But I get the error:
Type 'typeof TransportStream' is not a constructor function type.ts(2507)
I tried with several alternatives but always end up blocked by typescript compiler.
When I replace your import statement with
import Transport = require('winston-transport');
then tsc has no complaints. This is similar to how the built-in file transport imports winston-transport.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With