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
Added proper types for Helper Object and its methods. #14
base: dev
Are you sure you want to change the base?
Conversation
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.
Thanks, really nice in general. Here are some nits:)
/** | ||
* @typedef {Object} HelperType | ||
* @prop {() => string} getTSCCommand | ||
* @prop {() => string[]} resolveTSFiles | ||
* @prop {() => Command} getOptions | ||
*/ |
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.
I would personally favor adding this to the beginning, all the way before the "@typedef {import('commander').Command}" JSDoc comment (and in its own comment block).
* @prop {() => string[]} resolveTSFiles | ||
* @prop {() => Command} getOptions | ||
*/ | ||
/** @type {HelperType} */ |
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.
Correct but I will likely move it when I do the cleanup that I proposed in PR #9.
var Helper = {}; | ||
|
||
/** | ||
* Find tsc file executable path | ||
* | ||
* @returns {string} |
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.
I am not (yet) convinced to remove the return types. Yes my understanding is that return types can be "implicit" and that they are declared in the Helper type above. But I continue to really like the idea of making the types in JSDoc comments explicit, even for internal functions, like I would do this with JavaDoc comments. This remark applies to multiple places.
@@ -79,8 +83,6 @@ Helper.getTSCCommand = function () { | |||
|
|||
/** | |||
* Resolve ts file paths | |||
* | |||
* @returns {Array} |
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.
+1 for not using semi-useless "Array" type here
Here is what I would do:
* @returns {Array} | |
* | |
* @returns {string[]} |
@@ -96,7 +98,6 @@ Helper.resolveTSFiles = function () { | |||
|
|||
/** | |||
* Get command options | |||
* @returns {Command} |
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.
not (yet) convinced to get rid of this, as I said before
This is a simpler fix for you checkjs problem. Just needed to define the HelperType object with its methods and return types and then cast the Helper object to that type.