logdna-winston icon indicating copy to clipboard operation
logdna-winston copied to clipboard

Add types

Open Sytten opened this issue 4 years ago • 5 comments

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

Sytten avatar May 05 '20 20:05 Sytten

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

smusali avatar May 25 '20 21:05 smusali

Hey @smusali , any update on this?

saini-g avatar Sep 01 '20 11:09 saini-g

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.

Sytten avatar Sep 01 '20 15:09 Sytten

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));

saini-g avatar Sep 08 '20 12:09 saini-g

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
}

aq1018 avatar Jun 17 '21 03:06 aq1018