Skip to content

Commit

Permalink
update typing
Browse files Browse the repository at this point in the history
  • Loading branch information
khaitruong922 committed Oct 17, 2024
1 parent bdbc635 commit 1af5cde
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion ext/js/background/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,9 @@ export class Backend {
/** @type {import('translator').FindTermsMode} */
const mode = 'simple';
const options = this._getProfileOptions(optionsContext, false);
const details = {matchType: /** @type {import('translation').FindTermsMatchType} */ ('exact'), deinflect: true, reading: null};

/** @type {import('api').FindTermsDetails} */
const details = {matchType: 'exact', deinflect: true};
const findTermsOptions = this._getTranslatorFindTermsOptions(mode, details, options);
/** @type {import('api').ParseTextLine[]} */
const results = [];
Expand Down
6 changes: 3 additions & 3 deletions ext/js/display/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ export class Display extends EventDispatcher {
/**
* @param {boolean} isKanji
* @param {string} source
* @param {string | null} reading
* @param {string | undefined} reading
* @param {boolean} wildcardsEnabled
* @param {import('settings').OptionsContext} optionsContext
* @returns {Promise<import('dictionary').DictionaryEntry[]>}
Expand All @@ -1290,7 +1290,7 @@ export class Display extends EventDispatcher {

/**
* @param {string} source
* @param {string | null} reading
* @param {string | undefined} reading
* @param {boolean} wildcardsEnabled
* @returns {{findDetails: import('api').FindTermsDetails, source: string}}
*/
Expand Down Expand Up @@ -1321,7 +1321,7 @@ export class Display extends EventDispatcher {
async _setContentTermsOrKanji(type, urlSearchParams, token) {
const lookup = (urlSearchParams.get('lookup') !== 'false');
const wildcardsEnabled = (urlSearchParams.get('wildcards') !== 'off');
const reading = urlSearchParams.get('reading');
const reading = urlSearchParams.get('reading') ?? undefined;

Check failure on line 1324 in ext/js/display/display.js

View workflow job for this annotation

GitHub Actions / Static Analysis

Unexpected use of undefined
const hasEnabledDictionaries = this._options ? this._options.dictionaries.some(({enabled}) => enabled) : false;

// Set query
Expand Down
2 changes: 1 addition & 1 deletion types/ext/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import type {
export type FindTermsDetails = {
matchType?: Translation.FindTermsMatchType;
deinflect?: boolean;
reading: string | null;
reading?: string;
};

export type ParseTextResultItem = {
Expand Down
2 changes: 1 addition & 1 deletion types/ext/translation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export type FindTermsOptions = {
/**
* Exact reading of the term.
*/
reading: string | null;
reading: string | undefined;
/**
* The name of the primary dictionary to search.
*/
Expand Down

0 comments on commit 1af5cde

Please sign in to comment.