logdna / logdna-winston

LogDNA's Node.js logging module with support for Winston
MIT License
16 stars 14 forks source link

Add types #18

Open Sytten opened 4 years ago

Sytten commented 4 years ago

Hi! I am using logdna in a typescript project, would it possible to create the .d.ts files to help us out there? Thanks!

smusali commented 4 years ago

Hey @Sytten, thanks for bringing this up and suggesting the fix! I have already added some comments there.

saini-g commented 4 years ago

Hey @smusali , any update on this?

Sytten commented 4 years ago

Like I said in the Pr I do not have the bandwidth nor the interest to do another revision of it. It is better that someone from logdna does it so it respects their standard.

saini-g commented 4 years ago

Using the old require syntax worked for me. But it would be nice to have the type definitions created

const LogdnaWinston = require('logdna-winston');

const logger = winston.createLogger({
  level: 'info,
  transports: [],
});

const options = {
  key: '...',
  app: '...'
};
logger.add(new LogdnaWinston(options));
aq1018 commented 3 years ago

I had to make my own types for this package, just create a logdna-winston.d.ts on top level and copy paste this:

declare module 'logdna-winston' {
  import TransportStream, { TransportStreamOptions } from 'winston-transport'
  import { ConstructorOptions } from '@logdna/logger'

  type LogDNATransportOptions =
    Omit<ConstructorOptions, 'level'> &
    TransportStreamOptions & {
    key?: string
  }

  class LogDNATransport extends TransportStream {
    constructor(options: LogDNATransportOptions)
  }

  export = LogDNATransport
}