Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvNC committed Jul 20, 2024
1 parent b70625e commit b165e6d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ext/js/pages/settings/dictionary-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ class DictionaryEntry {
* @returns {boolean}
*/
_setupDetails(detailsTable) {
// /** @type {{[key in keyof (typeof this._dictionaryInfo & typeof this._dictionaryInfo.counts)]?: string}} */
/** @type {Partial<Record<keyof (typeof this._dictionaryInfo & typeof this._dictionaryInfo.counts), string>>} */
const targets = {
author: 'Author',
url: 'URL',
Expand All @@ -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;
Expand Down

0 comments on commit b165e6d

Please sign in to comment.