-
Notifications
You must be signed in to change notification settings - Fork 19
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
add type script declaration #33
Conversation
That's great taoqf! Thank you very much for your interest and willingness to help!! I am always looking for help, because I will never be able to build the ultimate logger alone. And you will be able to help shape what the solutions look like. I have been working on ulog v2 for a long time now, and it changed a lot between v1 and the early betas, but currently I am at a point where I feel the basic design has stabilized and other people can come on board and contribute, so if you are willing to do so then thank you! About your PR. Can you give me some instructions on how to test this? And how exactly did you make this? Did you copy-paste some code perhaps? I am asking because I see this: assert(...args: any[]): void
dir(...args: any[]): void
table(...args: any[]): void
time(...args: any[]): void
timeEnd(...args: any[]): void
verbose(message?: any, ...args: any[]): void
silly(message?: any, ...args: any[]): void These methods don't actually exist on all loggers. Also, we have the complex situation that methods and properties are being added to module.exports = {
extend: {
settings: {},
get: function() { /* ... */ },
set: function() { /* ... */ },
}
} So this mod adds a I have no idea how to model this with Typescript... Maybe mods could include their own typescript definitions? So maybe we should start simpler and first make the base typescript definition that extends the one from ulog.mods = []
ulog.use = function(mod) { /* ... */ } I can imagine we could maybe make a typescript definition for all standard entries. What I mean by that is that I am planning on providing a bunch of standard configurations of mods:
I have to admit that this is not fully thought out yet. I am still experimenting. So maybe for now we should focus on the |
@jirutka Thanks for the heads up! @taoqf Thank you for wanting to help out, but I need you to respect authorship. If Jakub did the work, he should get credit for it. So please keep this in mind when creating PRs. |
} | ||
|
||
declare namespace Logger { | ||
function use(options: Partial<Middleware>): void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, I add a method to Logger. you can add mods as well:
declare const mods: unknown[];
I use some code of @jirutka 's. @Download, I am not very familiar with the lib, just add some typescript based on @jirutka 's pr. |
@taoqf @jirutka If you both agree, we could maybe make a 'community effort' PR and you both will be credited along with anyone else that steps in to help. Adding the tests is very worthwhile @taoqf . In essence, you did nothing wrong by copy-pasting code; that's why we do Open Source to begin with, so we can use each other's work. Only thing is that most of us want to be credited for the work. So if we sort that out we should be good to go I hope. Do you both agree? |
I am new to ulog and find this is a excellent lib, I want to help with typescript. this will work for all example in readme.