Its-Alex/winston-node-sentry

import Transport from 'winston-transport'; error: has no default export

Fuco1 opened this issue · 11 comments

Fuco1 commented

I'm importing

import { SentryTransport } from 'winston-node-sentry/dist';

when I do a typecheck with tsc I get

$ tsc --noEmit
node_modules/winston-node-sentry/dist/index.d.ts:1:8 - error TS1192: Module '"/home/matus/dev/baas-serverless/node_modules/winston-transport/index"' has no default export.

1 import Transport from 'winston-transport';
         ~~~~~~~~~


Found 1 error.
Fuco1 commented

Changing the line in the file to

import * as Transport from 'winston-transport';

seems to fix the issue.

What's your problem ?

Because I always have an error about winston-transport if I use your solution I has error about it too.

$ tsc --noEmit dist/index.d.ts
dist/index.d.ts:11:56 - error TS2339: Property 'default' does not exist on type 'typeof TransportStream'.

11 export declare class SentryTransport extends Transport.default {
                                                          ~~~~~~~
Found 1 error.

In two case it can compile but error is here

Fuco1 commented

I'm doing the type-check on my program which uses this library as dependency. But I can not compile my code because I get the error in OP.

I'm no typescript expert so I'm not sure what the solution is.

Ok, I will check this weekend thanks for reporting it !

Fuco1 commented

I'm going to test this right away, I'll keep you updated!

Fuco1 commented

I now get another error

node_modules/winston-node-sentry/dist/index.d.ts:11:56 - error TS2339: Property 'default' does not exist on type 'typeof TransportStream'.

11 export declare class SentryTransport extends Transport.default {
                                                          ~~~~~~~


Found 1 error.

if I remove .default then it works fine. I think the * as Transport already uses the default export?

For my case I can't compile without the default, can you provide me the skeleton project where I can reproduce your error ?

Fuco1 commented

I'll try to create something but in the meantime we switched to a different package because we needed this to go live on friday

I see that you import from 'winston-node-sentry/dist' that might be a cause of this error, I close this issue because you didn't answer