Skip to content

Commit 2e26f16

Browse files
committed
Fix JSDoc typing for useCallback-wrapped callbacks
1 parent 5370c39 commit 2e26f16

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/sidebar/components/Annotation/AnnotationEditor.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,21 @@ function AnnotationEditor({
5757
const isEmpty = !text && !tags.length;
5858

5959
const onEditTags = useCallback(
60+
/** @param {string[]} tags */
6061
tags => {
6162
store.createDraft(draft.annotation, { ...draft, tags });
6263
},
6364
[draft, store]
6465
);
6566

66-
/**
67-
* Verify `newTag` has content and is not a duplicate; add the tag
68-
*
69-
* @param {string} newTag
70-
* @return {boolean} - `true` if tag is added
71-
*/
7267
const onAddTag = useCallback(
68+
/**
69+
* Verify `newTag` has content and is not a duplicate; add the tag
70+
*
71+
* @param {string} newTag
72+
* @return {boolean} Tag was added to the draft's tags; `false` if duplicate
73+
* or empty
74+
*/
7375
newTag => {
7476
if (!newTag || tags.indexOf(newTag) >= 0) {
7577
// don't add empty or duplicate tags
@@ -84,13 +86,13 @@ function AnnotationEditor({
8486
[onEditTags, tags, tagsService]
8587
);
8688

87-
/**
88-
* Remove a tag from the annotation.
89-
*
90-
* @param {string} tag
91-
* @return {boolean} - `true` if tag extant and removed
92-
*/
9389
const onRemoveTag = useCallback(
90+
/**
91+
* Remove tag from draft if present.
92+
*
93+
* @param {string} tag
94+
* @return {boolean} Tag removed from draft
95+
*/
9496
tag => {
9597
const newTagList = [...tags]; // make a copy
9698
const index = newTagList.indexOf(tag);
@@ -115,6 +117,7 @@ function AnnotationEditor({
115117
* @param {boolean} isPrivate
116118
*/
117119
const onSetPrivate = useCallback(
120+
/** @param {boolean} isPrivate */
118121
isPrivate => {
119122
store.createDraft(annotation, {
120123
...draft,

0 commit comments

Comments
 (0)