winston-graylog2
winston-graylog2 copied to clipboard
Update TypeScript typings for the latest (v2.0.0) version
https://github.com/namshi/winston-graylog2/releases/tag/v2.0.0 contains breaking changes that must be reflected in TS typings as well.
Typescript types are still broken (by this very change). Hopefully we can get a PR in, this is blocking us.
Feel free to send a pr :)
@popbee
Typescript types are still broken (by this very change). Hopefully we can get a PR in, this is blocking us.
What error do you get? Please provide more info, so I'll be able to fix it. Ideally, a TS code sample, that doesn't compile.
Thank you for considering this issue.
As soon as we can, we'll try to get the exact error, something to repro or even directly a PR. Essentially we are just setting it up normally with Winston. There isn't much in there and TSC just fails doing type checking, pointing to this library installed in node_module/ (not pointing to our code). (I haven't tried, but potentially just having const winstonGraylog2 = require('winston-graylog2');
is enough to trig the issue. I could be wrong thought.
We are compiling with the "real" Typescript (not Babel) and the Typescript version is 3.0.1.
@popbee sorry for a late reply, missed your message somehow. The following code compiles fine for me:
import * as winston from "winston";
import * as WinstonGraylog2 from "winston-graylog2";
const options = {
graylog: {
servers: [
{
host: "127.0.0.1",
port: 12201,
},
],
},
};
const graylog2Transport = new WinstonGraylog2(options);
const logger = winston.createLogger({
exitOnError: true,
transports: [graylog2Transport]
});
logger.info("Hello there!", {some: 42, doge: 12});
And this one:
const winston = require("winston");
const WinstonGraylog2 = require("winston-graylog2");
const options = {
graylog: {
servers: [
{
host: "127.0.0.1",
port: 12201,
},
],
},
};
const graylog2Transport = new WinstonGraylog2(options);
const logger = winston.createLogger({
exitOnError: true,
transports: [graylog2Transport]
});
logger.info("Hello there!", {some: 42, doge: 12});
Although, I personally don't use require
s with TypeScript. Here's the tsconfig.json
I used:
{
"compilerOptions": {
"outDir": "build",
"module": "commonjs",
"target": "ES2017"
},
"include": [
"src"
]
}
Hello @schfkt, your example code above does trigger Typescript errors for me using latest Winston 3.2.1.
Argument of type '{ exitOnError: true; transports: Graylog2Transport[]; }' is not assignable to parameter of type 'LoggerOptions'.
Types of property 'transports' are incompatible.
Type 'Graylog2Transport[]' is not assignable to type 'TransportStream | TransportStream[] | undefined'.
Type 'Graylog2Transport[]' is not assignable to type 'TransportStream[]'.
Type 'Graylog2Transport' is missing the following properties from type 'TransportStream': writable, writableHighWaterMark, writableLength, _write, and 24 more.ts(2345)
Also, I wondered if your library works out of the box with Graylog 3.0.
Best -act