-
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
custom level not work in typescript #1523
Comments
Facing the same issue. Do we need to define a custom type here or is there some other way how this can be achieved? |
So I ended up using Declaration Merging @types/winston/index.d.ts
Modified your code
Not sure if this is the best way to work with this, but this works for now. Waiting to hear if this can be done in a better way. |
@sachinh19 it's work! Thanks for your reply |
Another alternative is to just extend the
|
Both of these are nice solutions. Not closing this yet because I think it would be a good idea to get some of these "FAQ"-type issues into some examples somewhere. We don't have any TS-specific examples yet but maybe we can add a |
I am supportive of |
If only they'd change from declare namespace to declare module...then the module could just be augmented externally. 😢 |
It would be even better if each logger could infer levels from the For example, we could make it infer the levels in this example: const logger = winston.createLogger({
levels: { custom: 0 },
});
// works:
logger.custom('stuff');
logger.log('custom', 'stuff');
// compile error:
logger.info('stuff');
logger.log('info', 'stuff'); I'm happy to work on a PR when I get some free time. Edit: I realize maybe this can't be done since Winston can be augmented on the fly with |
you could check out this answer on StackOverflow. works pretty well for my use case |
Please tell us about your environment:
winston
version?winston@2
winston@3
node -v
outputs:_v8.12.0What is the problem?
custom level not work in typescript 3.1.3
code
The text was updated successfully, but these errors were encountered: