From dd7ff7e6620bb14866c2512327213a2552a22623 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sat, 25 Nov 2023 18:00:40 +0100 Subject: [PATCH] Update the JSDoc comments for the new TypeScript version 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. --- web/pdf_viewer.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js index af54eb1d9..b9ad52f19 100644 --- a/web/pdf_viewer.js +++ b/web/pdf_viewer.js @@ -2204,9 +2204,6 @@ class PDFViewer { ]); } - /** - * @type {number} - */ get annotationEditorMode() { return this.#annotationEditorUIManager ? this.#annotationEditorMode @@ -2214,7 +2211,15 @@ class PDFViewer { } /** - * @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) {