Skip to content

Commit

Permalink
Update the JSDoc comments for the new TypeScript version
Browse files Browse the repository at this point in the history
This commit fixes the JSDoc comment for the `annotationEditorMode` setter.
The types tests fail on that now because the input value was changed from
a number to an object with various properties in recent patches, but the
JSDoc comment was not updated accordingly.

Moreover, the types tests also fail because TypeScript 5.3 assumes that
getters and setters have equal return and input value types, which is
arguably also what one would expect, but our `annotationEditorMode`
getter and setter deviate from that because the getter returns a number
while the setter accepts an object. Given that it seems more important
to document the setter entirely, including the meaning and types of its
properties, and the type of the getter can easily be inferred from this
comment and the other JSDoc comments that have `annotationEditorMode` in
it, we remove the getter type to make the types tests pass again.
  • Loading branch information
timvandermeij committed Nov 25, 2023
1 parent 8aa26fa commit dd7ff7e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions web/pdf_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2204,17 +2204,22 @@ class PDFViewer {
]);
}

/**
* @type {number}
*/
get annotationEditorMode() {
return this.#annotationEditorUIManager
? this.#annotationEditorMode
: AnnotationEditorType.DISABLE;
}

/**
* @param {number} mode - AnnotationEditor mode (None, FreeText, Ink, ...)
* @typedef {Object} AnnotationEditorModeOptions
* @property {number} mode - The editor mode (none, FreeText, ink, ...).
* @property {string|null} [editId] - ID of the existing annotation to edit.
* @property {boolean} [isFromKeyboard] - True if the mode change is due to a
* keyboard action.
*/

/**
* @param {AnnotationEditorModeOptions} options
*/
set annotationEditorMode({ mode, editId = null, isFromKeyboard = false }) {
if (!this.#annotationEditorUIManager) {
Expand Down

0 comments on commit dd7ff7e

Please sign in to comment.