I'm trying to manually create types for winston-syslog (direct link to main file) in node, but I'm having issues. When I create the following definitions:
// File: src/types/winston-syslog/index.d.ts
declare module 'winston-syslog' {
import * as Transport from 'winston-transport';
export interface SyslogTransportOptions extends Transport.TransportStreamOptions {
host?: string;
port?: number;
path?: string;
protocol?: string;
pid?: number;
facility?: string;
localhost?: string;
type?: string;
app_name?: string;
eol?: string;
levels?: {[key: string]: number};
}
export interface Syslog extends Transport {
new(options?: SyslogTransportOptions): Syslog;
}
}
I can't create instances of Syslog, as Typescript fails with the error:
error TS2693: 'Syslog' only refers to a type, but is being used as a value here.
This is my (heavily reduced) main file:
// File: src/Log.ts
import {Syslog, SyslogTransportOptions} from 'winston-syslog';
const transportOptions = {/* some values here */};
const syslogTransport = new Syslog(transportOptions);
I'm guessing there's something wrong with how I defined the Syslog class, but this is exactly how it is done in winston internally.