diff options
author | Brandon Rainey <83629154+brandonrainey@users.noreply.github.com> | 2024-05-28 12:19:43 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-28 16:19:43 +0000 |
commit | 538ffccfae85116228e3f986a1659add927adf69 (patch) | |
tree | 6dcf04f3fbaf5f7fb261b38a92e12c025adadf6f | |
parent | e1c3613da0189c9c234d59d4474cfc3f958af79d (diff) |
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
-rw-r--r-- | ext/js/background/backend.js | 14 | ||||
-rw-r--r-- | types/ext/backend.d.ts | 2 |
2 files changed, 9 insertions, 7 deletions
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) { diff --git a/types/ext/backend.d.ts b/types/ext/backend.d.ts index c7d66522..da4deb49 100644 --- a/types/ext/backend.d.ts +++ b/types/ext/backend.d.ts @@ -37,3 +37,5 @@ export type CanAddResults = { canAddArray: {note: import('anki').Note, isDuplicate: boolean}[]; cannotAddArray: import('anki').Note[]; }; + +export type Mode = 'existingOrNewTab' | 'newTab' | 'popup'; |