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

Typescript: Type 'LoggingWinston[]' is not assignable to type 'TransportStream[]'. #342

Closed
Lukas-Kullmann opened this issue Jun 14, 2019 · 0 comments · Fixed by #348
Closed
Assignees
Labels
api: logging Issues related to the googleapis/nodejs-logging-winston API. type: question Request for information or clarification. Not an issue.

Comments

@Lukas-Kullmann
Copy link

Environment details

  • OS: Ubuntu 18
  • Node.js version: 10.16.0
  • npm version: 6.9.0
  • typscript version: 3.5.1
  • winston version: 3.2.1 (also reproducable with 3.1.0)
  • @google-cloud/logging-winston version: 1.0.0

Steps to reproduce

It's basically the same issue as #129.

  1. Try setting up winston
import { LoggingWinston } from '@google-cloud/logging-winston';
import winston from 'winston';

winston.createLogger({
  transports: [
    new LoggingWinston(),
  ],
});
  1. Typescript throws an error
Error:(5,3) TS2322: Type 'LoggingWinston[]' is not assignable to type 'TransportStream | TransportStream[]'.
  Type 'LoggingWinston[]' is not assignable to type 'TransportStream[]'.
    Type 'LoggingWinston' is missing the following properties from type 'TransportStream': writable, writableHighWaterMark, writableLength, _write, and 24 more.

Fix

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

Changing the typings of @google-cloud/logging-winston/index.d.ts resolves the problem:

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

See also the typescript documentation on AMD and CommonJS modules.

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Jun 15, 2019
@sduskis sduskis added type: question Request for information or clarification. Not an issue. and removed triage me I really want to be triaged. labels Jun 16, 2019
ofrobots added a commit to ofrobots/nodejs-logging-winston that referenced this issue Jun 17, 2019
`transport-stream` uses a CommonJS style export. The way we were
importing was giving errors to using `esModuleInterop`. Use the special
syntax for this style of modules.

Fixes: googleapis#341
Fixes: googleapis#342
ofrobots added a commit that referenced this issue Jun 17, 2019
`transport-stream` uses a CommonJS style export. The way we were
importing was giving errors to using `esModuleInterop`. Use the special
syntax for this style of modules.

Fixes: #341
Fixes: #342
@google-cloud-label-sync google-cloud-label-sync bot added the api: logging Issues related to the googleapis/nodejs-logging-winston API. label Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/nodejs-logging-winston API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants