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

Argument of type 'UDPTransport' is not assignable to parameter of type 'TransportStream' #13

Closed
nikkonrom opened this issue Dec 16, 2020 · 1 comment · Fixed by #14
Closed
Assignees

Comments

@nikkonrom
Copy link

Environment details

  • OS: macOS 10.15.7
  • Node.js version: 14.13.0
  • npm version: 6.14.18
  • typscript version: 4.0.3
  • winston version: 3.3.3 (also reproducable with 3.2.1)
  • udp-transport-winston version: 1.1.7

Steps to reproduce

  1. Try setting up winston:
import {config} from './config'
import {createLogger, transports, Logger} from 'winston'
import {UDPTransport} from 'udp-transport-winston';

const logger: Logger = createLogger({
  level: config.get('logging.level'),
  exitOnError: false
})
logger.add(new UDPTransport({
    host: config.get('logging.transports.udp.host'),
    port: config.get('logging.transports.udp.port')
  }))
  1. Typescript throws an error:
error TS2345: Argument of type 'UDPTransport' is not assignable to parameter of type 'TransportStream'.
  Type 'UDPTransport' is missing the following properties from type 'TransportStream': writable, writableEnded, writableFinished, writableHighWaterMark, and 29 more.

Fix

The problem is that winston-transport defines the export of TransportStream via export =.

Changing the typings of udp-transport-winston/src/udp-transport.ts resolves the problem:

-import * as Transport from 'winston-transport';
+import Transport = require('winston-transport');

Similar issues: googleapis/nodejs-logging-winston#129, microsoft/TypeScript#29505, googleapis/nodejs-logging-winston#342
See also: typescript documentation on AMD and CommonJS modules

@raz6tamir
Copy link
Owner

Thank you for the issue. I will look into it.
Seems this is related to typescript v4.

@raz6tamir raz6tamir self-assigned this Dec 17, 2020
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

Successfully merging a pull request may close this issue.

2 participants