Skip to content

Fix .description(): do not set command description if undefined is provided in the first parameter#1966

Closed
aweebit wants to merge 1 commit intotj:developfrom
aweebit:fix/undefined-command-description
Closed

Fix .description(): do not set command description if undefined is provided in the first parameter#1966
aweebit wants to merge 1 commit intotj:developfrom
aweebit:fix/undefined-command-description

Conversation

@aweebit
Copy link
Copy Markdown
Contributor

@aweebit aweebit commented Aug 13, 2023

This is a ridiculously unimportant change, but it fixes one of the errors revealed by a run of the TypeScript check fixed in #1960.

I've learnt my lesson, and since the change is technically visible to the outside world, I am making a separate PR for it.

Peer PRs

Changes are to be merged into…

@@ -1837,7 +1837,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
*/
description(str, argsDescription) {
if (str === undefined && argsDescription === undefined) return this._description;
Copy link
Copy Markdown
Contributor Author

@aweebit aweebit Aug 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative solution not allowing to change only the arguments description:

Suggested change
if (str === undefined && argsDescription === undefined) return this._description;
if (str === undefined) return this._description;

(and leave the next line untouched)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually like this alternative solution better, and argsDescription is deprecated. But it would technically be a breaking change. I think simpler just to leave it alone (and one day get rid of argsDescription).

@aweebit aweebit mentioned this pull request Aug 13, 2023
@shadowspawn
Copy link
Copy Markdown
Collaborator

Can revisit this if/when it gets in the way of adding more strict checks to the JavaScript.

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.

2 participants