aboutsummaryrefslogtreecommitdiff
path: root/types
diff options
context:
space:
mode:
Diffstat (limited to 'types')
-rw-r--r--types/ext/translation.d.ts7
-rw-r--r--types/test/translator.d.ts11
2 files changed, 17 insertions, 1 deletions
diff --git a/types/ext/translation.d.ts b/types/ext/translation.d.ts
index 604dbda6..c9a61be0 100644
--- a/types/ext/translation.d.ts
+++ b/types/ext/translation.d.ts
@@ -107,7 +107,7 @@ export type FindTermsOptions = {
/**
* An iterable sequence of text replacements to be applied during the term lookup process.
*/
- textReplacements: (FindTermsTextReplacement[] | null)[];
+ textReplacements: FindTermsTextReplacements;
/**
* The mapping of dictionaries to search for terms in.
* The key is the dictionary name.
@@ -158,6 +158,11 @@ export type FindTermsTextReplacement = {
};
/**
+ * Multiple text replacements.
+ */
+export type FindTermsTextReplacements = (FindTermsTextReplacement[] | null)[];
+
+/**
* Details about a dictionary.
*/
export type FindTermDictionary = {
diff --git a/types/test/translator.d.ts b/types/test/translator.d.ts
index b213f9e0..e3199225 100644
--- a/types/test/translator.d.ts
+++ b/types/test/translator.d.ts
@@ -16,6 +16,7 @@
*/
import type {FindTermsMatchType, FindTermsSortOrder, FindTermsVariantMode, FindTermsEmphaticSequencesMode, FindKanjiDictionary, FindTermDictionary} from '../ext/translation';
+import type {SearchResolution} from 'settings';
import type {FindTermsMode} from 'translator';
import type {DictionaryEntry} from 'dictionary';
import type {NoteData} from 'anki-templates';
@@ -30,11 +31,13 @@ export type OptionsList = string | (string | OptionsPreset)[];
export type OptionsPreset = FindKanjiOptionsPreset | FindTermsOptionsPreset;
export type FindKanjiOptionsPreset = {
+ type: 'kanji';
enabledDictionaryMap?: [key: string, value: FindKanjiDictionary][];
removeNonJapaneseCharacters?: boolean;
};
export type FindTermsOptionsPreset = {
+ type: 'terms';
matchType?: FindTermsMatchType;
deinflect?: boolean;
mainDictionary?: string;
@@ -50,8 +53,16 @@ export type FindTermsOptionsPreset = {
textReplacements?: (FindTermsTextReplacement[] | null)[];
enabledDictionaryMap?: [key: string, value: FindTermDictionary][];
excludeDictionaryDefinitions?: string[] | null;
+ searchResolution?: SearchResolution;
};
+export type OptionsType = OptionsPreset['type'];
+
+export type OptionsPresetGeneric<T extends OptionsType> = {
+ kanji: FindKanjiOptionsPreset;
+ terms: FindTermsOptionsPreset;
+}[T];
+
export type FindTermsTextReplacement = {
pattern: string;
flags: string;