Skip to content
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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

rbiggs
Copy link

@rbiggs rbiggs commented Nov 3, 2019

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.

Copy link
Owner

@brodybits brodybits left a 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:)

Comment on lines +62 to +67
/**
* @typedef {Object} HelperType
* @prop {() => string} getTSCCommand
* @prop {() => string[]} resolveTSFiles
* @prop {() => Command} getOptions
*/
Copy link
Owner

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} */
Copy link
Owner

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}
Copy link
Owner

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}
Copy link
Owner

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:

Suggested change
* @returns {Array}
*
* @returns {string[]}

@@ -96,7 +98,6 @@ Helper.resolveTSFiles = function () {

/**
* Get command options
* @returns {Command}
Copy link
Owner

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

@brodybits
Copy link
Owner

I just raised PR #16 to cleanup the exported helper object, and I think it would affect this PR. Feedback on PR #16 would be much appreciated.

I wouldn't mind if you want to combine this PR & #16 together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants