@@ -158,6 +158,9 @@ export interface ITranslateResult {
158
158
export const ISV_SRC = 'isv-src'
159
159
export const ISV = 'isv'
160
160
161
+ export type WordList = string [ ] [ ]
162
+ export type SearchIndex = Record < string , Array < [ string , string [ ] ] > >
163
+
161
164
class DictionaryClass {
162
165
public static getInstance ( ) : DictionaryClass {
163
166
if ( ! DictionaryClass . instance ) {
@@ -173,7 +176,7 @@ class DictionaryClass {
173
176
private langsList : string [ ]
174
177
private headerIndexes : Map < string , number >
175
178
private percentsOfChecked : { [ lang : string ] : string }
176
- private words : string [ ] [ ]
179
+ private words : WordList
177
180
private splittedMap : { [ lang : string ] : Map < string , string [ ] > }
178
181
private isvSearchLetters : { from : string [ ] , to : string [ ] }
179
182
private isvSearchByWordForms : boolean
@@ -188,9 +191,9 @@ class DictionaryClass {
188
191
}
189
192
190
193
public init (
191
- wordList : string [ ] [ ] ,
192
- searchIndex ?: any | false ,
193
- percentsOfChecked ?: any ,
194
+ wordList : WordList ,
195
+ searchIndex ?: SearchIndex ,
196
+ percentsOfChecked ?: Record < string , string > ,
194
197
) : number {
195
198
let startInitTime = 0
196
199
@@ -284,7 +287,7 @@ class DictionaryClass {
284
287
285
288
return initTime
286
289
}
287
- public addLang ( wordList : string [ ] , searchIndex ?: any ) {
290
+ public addLang ( wordList : string [ ] , searchIndex ?: SearchIndex ) {
288
291
const lang = wordList [ 0 ]
289
292
290
293
if ( this . hasLang ( lang ) ) {
@@ -303,15 +306,15 @@ class DictionaryClass {
303
306
public hasLang ( lang ) : boolean {
304
307
return this . headerIndexes . has ( lang )
305
308
}
306
- public getWordList ( ) : string [ ] [ ] {
309
+ public getWordList ( ) : WordList {
307
310
return this . words
308
311
}
309
312
public getWord ( wordId : string ) {
310
313
if ( this . words && this . words . length ) {
311
314
return this . words . filter ( ( line ) => this . getField ( line , 'id' ) === wordId ) [ 0 ]
312
315
}
313
316
}
314
- public getIndex ( ) {
317
+ public getIndex ( ) : SearchIndex {
315
318
const searchIndex = { } ;
316
319
317
320
[
@@ -326,7 +329,7 @@ class DictionaryClass {
326
329
327
330
return searchIndex
328
331
}
329
- public translate ( translateParams : ITranslateParams , showTime = true ) : [ string [ ] [ ] , number ] {
332
+ public translate ( translateParams : ITranslateParams , showTime = true ) : [ WordList , number ] {
330
333
const {
331
334
inputText,
332
335
from,
@@ -517,7 +520,7 @@ class DictionaryClass {
517
520
}
518
521
519
522
public formatTranslate (
520
- results : string [ ] [ ] ,
523
+ results : WordList ,
521
524
from : string ,
522
525
to : string ,
523
526
flavorisationType : string ,
0 commit comments