diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2023-12-15 20:31:48 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-16 01:31:48 +0000 |
commit | c312e7a55114b913afcd85d92f2bf1006b8af246 (patch) | |
tree | 431428468ae5e2f643ee0036b6504fba4757c7df | |
parent | 730b34c0bbe394fd62afb20b32152139a65b0b60 (diff) |
Fix usage of any (*) type in DocumentUtil (#361)
-rw-r--r-- | ext/js/dom/document-util.js | 19 | ||||
-rw-r--r-- | ext/js/language/text-scanner.js | 6 | ||||
-rw-r--r-- | types/ext/text-scanner.d.ts | 6 |
3 files changed, 12 insertions, 19 deletions
diff --git a/ext/js/dom/document-util.js b/ext/js/dom/document-util.js index b2aa8f81..0153e74a 100644 --- a/ext/js/dom/document-util.js +++ b/ext/js/dom/document-util.js @@ -100,22 +100,9 @@ export class DocumentUtil { * @param {boolean} layoutAwareScan Whether or not layout-aware scan mode should be used. * @param {number} extent The length of the sentence to extract. * @param {boolean} terminateAtNewlines Whether or not a sentence should be terminated at newline characters. - * @param {Map<string, *[]>} terminatorMap A mapping of characters that terminate a sentence. - * Format: - * ```js - * new Map([ [character: string, [includeCharacterAtStart: boolean, includeCharacterAtEnd: boolean]], ... ]) - * ``` - * @param {Map<string, *[]>} forwardQuoteMap A mapping of quote characters that delimit a sentence. - * Format: - * ```js - * new Map([ [character: string, [otherCharacter: string, includeCharacterAtStart: boolean]], ... ]) - * ``` - * @param {Map<string, *[]>} backwardQuoteMap A mapping of quote characters that delimit a sentence, - * which is the inverse of forwardQuoteMap. - * Format: - * ```js - * new Map([ [character: string, [otherCharacter: string, includeCharacterAtEnd: boolean]], ... ]) - * ``` + * @param {import('text-scanner').SentenceTerminatorMap} terminatorMap A mapping of characters that terminate a sentence. + * @param {import('text-scanner').SentenceForwardQuoteMap} forwardQuoteMap A mapping of quote characters that delimit a sentence. + * @param {import('text-scanner').SentenceBackwardQuoteMap} backwardQuoteMap A mapping of quote characters that delimit a sentence, which is the inverse of forwardQuoteMap. * @returns {{text: string, offset: number}} The sentence and the offset to the original source. */ static extractSentence(source, layoutAwareScan, extent, terminateAtNewlines, terminatorMap, forwardQuoteMap, backwardQuoteMap) { diff --git a/ext/js/language/text-scanner.js b/ext/js/language/text-scanner.js index d1b033e6..3de16f54 100644 --- a/ext/js/language/text-scanner.js +++ b/ext/js/language/text-scanner.js @@ -102,11 +102,11 @@ export class TextScanner extends EventDispatcher { this._sentenceScanExtent = 0; /** @type {boolean} */ this._sentenceTerminateAtNewlines = true; - /** @type {Map<string, [includeCharacterAtStart: boolean, includeCharacterAtEnd: boolean]>} */ + /** @type {import('text-scanner').SentenceTerminatorMap} */ this._sentenceTerminatorMap = new Map(); - /** @type {Map<string, [character: string, includeCharacterAtStart: boolean]>} */ + /** @type {import('text-scanner').SentenceForwardQuoteMap} */ this._sentenceForwardQuoteMap = new Map(); - /** @type {Map<string, [character: string, includeCharacterAtEnd: boolean]>} */ + /** @type {import('text-scanner').SentenceBackwardQuoteMap} */ this._sentenceBackwardQuoteMap = new Map(); /** @type {import('text-scanner').InputConfig[]} */ this._inputs = []; diff --git a/types/ext/text-scanner.d.ts b/types/ext/text-scanner.d.ts index 4ec7f204..5b806dab 100644 --- a/types/ext/text-scanner.d.ts +++ b/types/ext/text-scanner.d.ts @@ -184,3 +184,9 @@ export type PointerEventType = ( 'click' | 'script' ); + +export type SentenceTerminatorMap = Map<string, [includeCharacterAtStart: boolean, includeCharacterAtEnd: boolean]>; + +export type SentenceForwardQuoteMap = Map<string, [character: string, includeCharacterAtStart: boolean]>; + +export type SentenceBackwardQuoteMap = Map<string, [character: string, includeCharacterAtEnd: boolean]>; |