-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 errors creating custom transport #1382
Comments
If I take your example, |
I'm facing a similar issue here. My code: import * as Transport from 'winston-transport'
// import Transport from 'winston-transport';
export class CustomLogger extends Transport {
constructor(opts: any) {
super(opts);
}
log(info, callback) {
setImmediate(() => {
this.emit('logged', info);
});
// Log Stuff
if (callback) {
callback();
}
}
} and i get: lib/CustomLogger.ts:4:35 - error TS2507: Type 'typeof TransportStream' is not a constructor function type.
4 export class CustomLogger extends Transport {
lib/CustomLogger.ts:8:7 - error TS7006: Parameter 'info' implicitly has an 'any' type.
8 log(info, callback) {
lib/CustomLogger.ts:8:13 - error TS7006: Parameter 'callback' implicitly has an 'any' type.
8 log(info, callback) {
lib/CustomLogger.ts:10:12 - error TS2339: Property 'emit' does not exist on type 'CustomLogger'.
10 this.emit('logged', info);
Found 4 errors. using: "dependencies": {
"winston": "^3.2.1",
"winston-transport": "^4.3.0"
},
"devDependencies": {
"@types/node": "^12.0.7",
"typescript": "^3.5.1"
} more info:
Also asked at stack overflow |
Still happening in 2022. I have the exact same error as @opensas "dependencies": {
"winston": "3.7.2",
"winston-transport": "4.5.0"
},
"devDependencies": {
"typescript": "4.7.2"
}
Fixedimport Transport from 'winston-transport'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please tell us about your environment:
winston
version? 3.0.0winston@2
winston@3
node -v
outputs: v8.9.4What is the problem?
I'm trying to declare a new custom Transport.
I am seeing 2 compiler errors:
From
import Transport from 'winston-transport';
error TS1192: Module '".../node_modules/winston-transport/index"' has no default export.
In 3.0.0-rc5 this could be worked around by doing
From
this.emit('logged', info);
error TS2339: Property 'emit' does not exist on type 'AirbrakeLogger'.
I can work around this by doing
(this as any).emit('logged', info);
, but it's not pretty.What do you expect to happen instead?
No compiler errors?
Other information
The text was updated successfully, but these errors were encountered: