diff --git a/ext/js/pages/settings/dictionary-controller.js b/ext/js/pages/settings/dictionary-controller.js index eeb7f1c626..2abebbe2a9 100644 --- a/ext/js/pages/settings/dictionary-controller.js +++ b/ext/js/pages/settings/dictionary-controller.js @@ -296,6 +296,8 @@ class DictionaryEntry { * @returns {boolean} */ _setupDetails(detailsTable) { + // /** @type {{[key in keyof (typeof this._dictionaryInfo & typeof this._dictionaryInfo.counts)]?: string}} */ + /** @type {Partial>} */ const targets = { author: 'Author', url: 'URL', @@ -313,11 +315,11 @@ class DictionaryEntry { const dictionaryInfo = {...this._dictionaryInfo, ...this._dictionaryInfo.counts}; const fragment = document.createDocumentFragment(); let any = false; - for (const [key, label] of /** @type {([keyof typeof targets, string])[]} */ (Object.entries(targets))) { + for (const [key, label] of /** @type {([keyof (typeof this._dictionaryInfo & typeof this._dictionaryInfo.counts), string])[]} */ (Object.entries(targets))) { const info = dictionaryInfo[key]; const displayText = ((_info) => { if (typeof _info === 'string') { return _info; } - if (typeof _info?.total === 'number') { + if (_info && typeof _info === 'object' && 'total' in _info) { return _info.total ? `${_info.total}` : false; } return false;