Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TypeScript typings for the latest (v2.0.0) version #68

Open
schfkt opened this issue Jan 28, 2019 · 6 comments
Open

Update TypeScript typings for the latest (v2.0.0) version #68

schfkt opened this issue Jan 28, 2019 · 6 comments
Assignees

Comments

@schfkt
Copy link
Collaborator

schfkt commented Jan 28, 2019

https://github.com/namshi/winston-graylog2/releases/tag/v2.0.0 contains breaking changes that must be reflected in TS typings as well.

@popbee
Copy link

popbee commented Mar 21, 2019

Typescript types are still broken (by this very change). Hopefully we can get a PR in, this is blocking us.

@odino
Copy link
Contributor

odino commented Mar 22, 2019

Feel free to send a pr :)

@schfkt schfkt reopened this Mar 22, 2019
@schfkt
Copy link
Collaborator Author

schfkt commented Mar 22, 2019

@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.

@popbee
Copy link

popbee commented Mar 22, 2019

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.

@schfkt
Copy link
Collaborator Author

schfkt commented Apr 5, 2019

@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 requires with TypeScript. Here's the tsconfig.json I used:

{
  "compilerOptions": {
    "outDir": "build",
    "module": "commonjs",
    "target": "ES2017"
  },
  "include": [
    "src"
  ]
}

@actraiser
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants