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

ERROR:Type 'typeof TransportStream' is not a constructor function type. Version: typescript 3.5.3,

Open li1224632854 opened this issue 4 years ago • 9 comments

Type 'typeof TransportStream' is not a constructor function type. image

li1224632854 avatar Apr 29 '20 04:04 li1224632854

Any update about this?

ngocketit avatar May 07 '20 20:05 ngocketit

I think the issue is with the import. Changing it to: import TransportStream = require('winston-transport') fixes the issue

ngocketit avatar May 08 '20 07:05 ngocketit

does anyone use typescript and this import works?

import winstonGraylog2 from 'winston-graylog2';

I'm suspecting that language level or language feature may be an issue.

I'm failing with such tsconfig:

    "target": "es2016",
    // Enables experimental support for ES7 decorators.
    "experimentalDecorators": true,
    "esModuleInterop": true,

glensc avatar Jun 29 '20 12:06 glensc

possible fix in https://github.com/namshi/winston-graylog2/pull/76

glensc avatar Jun 29 '20 12:06 glensc

I can confirm that I can import this say okay and tsc no longer complain:

import * as WinstonGraylog2 from 'winston-graylog2';

glensc avatar Jun 29 '20 12:06 glensc

import * as WinstonGraylog2 from 'winston-graylog2';

Hi @glensc Tried this way but then the error exists

image

Type 'typeof TransportStream' is not a constructor function type.ts(2507)

naveenmscripts avatar Jun 29 '20 12:06 naveenmscripts

Do you have esModuleInterop enabled?

  • https://github.com/namshi/winston-graylog2/pull/83#issuecomment-651098968

glensc avatar Jun 29 '20 13:06 glensc

@glensc Yes it's enabled in my tsconfig file

naveenmscripts avatar Jun 29 '20 14:06 naveenmscripts

Sorry for the late reply guys. I no longer use this library myself, so I didn't really have time to check the issue. Here is the PR that allows to use the lib with both enabled/disabled esModuleInterop option: https://github.com/namshi/winston-graylog2/pull/84

schfkt avatar Jul 03 '20 09:07 schfkt