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 90a1d3d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 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,7 @@ class DictionaryEntry {
* @returns {boolean}
*/
_setupDetails(detailsTable) {
/** @type {Partial<Record<keyof (typeof this._dictionaryInfo & typeof this._dictionaryInfo.counts), string>>} */
const targets = {
author: 'Author',
url: 'URL',
Expand All @@ -313,11 +314,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 90a1d3d

Please sign in to comment.