I added the winston-logstash package, which is a winston transport for logstash. Unfortunately it comes without typescript definitions and I am struggling with adding my own typings to it.
What I have tried:
My winston.ts:
import { Logger, LoggerInstance, transports } from 'winston';
require('winston-logstash');
export const logger: LoggerInstance = new Logger({
transports: [
// Console Logger Settings
new transports.Console({
timestamp: tsFormat,
colorize: true,
silent: false,
prettyPrint: true,
level: 'debug'
}),
new transports.Logstash({
port: 28777,
node_name: 'my node name',
host: '127.0.0.1
})
],
exitOnError: false,
colors: {
trace: 'white',
debug: 'green',
info: 'blue',
warn: 'yellow',
crit: 'red',
fatal: 'red'
}
});
My types/winston-extend.d.ts:
declare module "winston-logstash" {
import winston = require("winston");
import { TransportInstance } from 'winston';
interface IOptions {
port: number;
node_name: string;
host: string;
}
interface Static {
new (opts: IOptions): Instance;
}
interface Instance extends winston.TransportInstance {
log(level: string, msg: string, meta: any, cb: Function);
}
interface Transports {
Logstash: Instance;
}
var Logstash: Static;
export = Logstash;
}
The error:
[ts] Property 'Logstash' does not exist on type 'Transports'
My question:
How do I properly add typescript definitions (specifically winston-logstash) for a winston transport?