From 538ffccfae85116228e3f986a1659add927adf69 Mon Sep 17 00:00:00 2001 From: Brandon Rainey <83629154+brandonrainey@users.noreply.github.com> Date: Tue, 28 May 2024 12:19:43 -0400 Subject: Change mode to enum (#992) * converted mode to an enum * converted mode to an enum * created a Mode type in backend.d.ts, reverted enum in backend.js to use this type instead * removed old comment --- ext/js/background/backend.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'ext/js/background/backend.js') diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index b9e23cbb..da720315 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -970,10 +970,10 @@ export class Backend { // Command handlers /** - * @param {undefined|{mode: 'existingOrNewTab'|'newTab'|'popup', query?: string}} params + * @param {undefined|{mode: import('backend').Mode, query?: string}} params */ async _onCommandOpenSearchPage(params) { - /** @type {'existingOrNewTab'|'newTab'|'popup'} */ + /** @type {import('backend').Mode} */ let mode = 'existingOrNewTab'; let query = ''; if (typeof params === 'object' && params !== null) { @@ -1042,10 +1042,10 @@ export class Backend { } /** - * @param {undefined|{mode: 'existingOrNewTab'|'newTab'|'popup'}} params + * @param {undefined|{mode: import('backend').Mode}} params */ async _onCommandOpenSettingsPage(params) { - /** @type {'existingOrNewTab'|'newTab'|'popup'} */ + /** @type {import('backend').Mode} */ let mode = 'existingOrNewTab'; if (typeof params === 'object' && params !== null) { mode = this._normalizeOpenSettingsPageMode(params.mode, mode); @@ -2552,7 +2552,7 @@ export class Backend { } /** - * @param {'existingOrNewTab'|'newTab'|'popup'} mode + * @param {import('backend').Mode} mode */ async _openSettingsPage(mode) { const manifest = chrome.runtime.getManifest(); @@ -2681,8 +2681,8 @@ export class Backend { /** * @param {unknown} mode - * @param {'existingOrNewTab'|'newTab'|'popup'} defaultValue - * @returns {'existingOrNewTab'|'newTab'|'popup'} + * @param {import('backend').Mode} defaultValue + * @returns {import('backend').Mode} */ _normalizeOpenSettingsPageMode(mode, defaultValue) { switch (mode) { -- cgit v1.2.3