From e9e504b40dde8691c32c933c7e27e28cfad1c8b5 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 19 Dec 2023 01:17:22 -0500 Subject: Template type improvements (#380) * Default templates to unknown * Default typescript templates to unknown * More template type updates --- types/ext/anki-templates-internal.d.ts | 2 +- types/ext/api.d.ts | 2 +- types/ext/cache-map.d.ts | 2 +- types/ext/core.d.ts | 2 +- types/ext/dictionary-data-util.d.ts | 2 +- types/ext/dictionary-database.d.ts | 6 +++--- types/ext/dictionary-worker.d.ts | 6 +++--- types/ext/dom-data-binder.d.ts | 24 ++++++++++++------------ types/ext/dynamic-property.d.ts | 2 +- types/ext/selector-observer.d.ts | 12 ++++++------ types/ext/task-accumulator.d.ts | 2 +- 11 files changed, 31 insertions(+), 31 deletions(-) (limited to 'types') diff --git a/types/ext/anki-templates-internal.d.ts b/types/ext/anki-templates-internal.d.ts index 4cb50050..2842765d 100644 --- a/types/ext/anki-templates-internal.d.ts +++ b/types/ext/anki-templates-internal.d.ts @@ -53,7 +53,7 @@ export type CreateDetails = { media?: AnkiTemplates.Media; }; -export type CachedValue = { +export type CachedValue = { getter: () => T; hasValue: boolean; value: T | undefined; diff --git a/types/ext/api.d.ts b/types/ext/api.d.ts index 2d78cc06..41d3a96d 100644 --- a/types/ext/api.d.ts +++ b/types/ext/api.d.ts @@ -34,7 +34,7 @@ import type * as Translator from './translator'; // Generic -export type Handler = ( +export type Handler = ( details: TDetails, sender: (THasSender extends true ? chrome.runtime.MessageSender : void) ) => (TResult | Promise); diff --git a/types/ext/cache-map.d.ts b/types/ext/cache-map.d.ts index 0af7109a..fcf969e8 100644 --- a/types/ext/cache-map.d.ts +++ b/types/ext/cache-map.d.ts @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -export type Node = { +export type Node = { key: K | null; value: V | null; previous: Node | null; diff --git a/types/ext/core.d.ts b/types/ext/core.d.ts index b83e6a74..d1a4ef8f 100644 --- a/types/ext/core.d.ts +++ b/types/ext/core.d.ts @@ -41,7 +41,7 @@ export type TokenString = string; export type TokenObject = Record; -export type DeferredPromiseDetails = { +export type DeferredPromiseDetails = { promise: Promise; resolve: (value: T) => void; reject: (reason?: RejectionReason) => void; diff --git a/types/ext/dictionary-data-util.d.ts b/types/ext/dictionary-data-util.d.ts index 75128368..b78e6439 100644 --- a/types/ext/dictionary-data-util.d.ts +++ b/types/ext/dictionary-data-util.d.ts @@ -45,7 +45,7 @@ export type KanjiFrequenciesMap2Data = { export type TermFrequenciesMap3 = Map; -export type DictionaryFrequency = { +export type DictionaryFrequency = { dictionary: string; frequencies: T[]; }; diff --git a/types/ext/dictionary-database.d.ts b/types/ext/dictionary-database.d.ts index 6569f76b..3202ef60 100644 --- a/types/ext/dictionary-database.d.ts +++ b/types/ext/dictionary-database.d.ts @@ -230,11 +230,11 @@ export type FindMultiBulkData = { indexIndex: number; }; -export type CreateQuery = (item: TItem) => (IDBValidKey | IDBKeyRange | null); +export type CreateQuery = (item: TItem) => (IDBValidKey | IDBKeyRange | null); -export type FindPredicate = (row: TRow, item: TItem) => boolean; +export type FindPredicate = (row: TRow, item: TItem) => boolean; -export type CreateResult = (row: TRow, data: FindMultiBulkData) => TResult; +export type CreateResult = (row: TRow, data: FindMultiBulkData) => TResult; export type DictionarySet = { has(value: string): boolean; diff --git a/types/ext/dictionary-worker.d.ts b/types/ext/dictionary-worker.d.ts index 17030691..ac076ab8 100644 --- a/types/ext/dictionary-worker.d.ts +++ b/types/ext/dictionary-worker.d.ts @@ -29,7 +29,7 @@ export type InvokeDetails = { formatResult: ((result: TResponseRaw) => TResponse) | null; }; -export type MessageCompleteData = { +export type MessageCompleteData = { action: 'complete'; params: MessageCompleteParams; }; @@ -44,7 +44,7 @@ export type MessageGetImageDetailsData = { params: MessageGetImageDetailsParams; }; -export type MessageCompleteParams = Core.Response; +export type MessageCompleteParams = Core.Response; export type MessageProgressParams = { args: unknown[]; @@ -56,7 +56,7 @@ export type MessageGetImageDetailsParams = { mediaType: string; }; -export type MessageData = MessageCompleteData | MessageProgressData | MessageGetImageDetailsData; +export type MessageData = MessageCompleteData | MessageProgressData | MessageGetImageDetailsData; export type MessageCompleteResultSerialized = { result: DictionaryImporter.Summary; diff --git a/types/ext/dom-data-binder.d.ts b/types/ext/dom-data-binder.d.ts index ca0036c3..5de941ff 100644 --- a/types/ext/dom-data-binder.d.ts +++ b/types/ext/dom-data-binder.d.ts @@ -17,28 +17,28 @@ import type * as TaskAccumulator from './task-accumulator'; -export type CreateElementMetadataCallback = (element: Element) => T | undefined; +export type CreateElementMetadataCallback = (element: Element) => T | undefined; -export type CompareElementMetadataCallback = (metadata1: T, metadata2: T) => boolean; +export type CompareElementMetadataCallback = (metadata1: T, metadata2: T) => boolean; -export type GetValuesCallback = (args: GetValuesDetails[]) => Promise; +export type GetValuesCallback = (args: GetValuesDetails[]) => Promise; -export type SetValuesCallback = (args: SetValuesDetails[]) => Promise; +export type SetValuesCallback = (args: SetValuesDetails[]) => Promise; -export type GetValuesDetails = { +export type GetValuesDetails = { element: Element; metadata: T; }; -export type SetValuesDetails = { +export type SetValuesDetails = { element: Element; metadata: T; value: ValueType; }; -export type OnErrorCallback = (error: Error, stale: boolean, element: Element, metadata: T) => void; +export type OnErrorCallback = (error: Error, stale: boolean, element: Element, metadata: T) => void; -export type ConstructorDetails = { +export type ConstructorDetails = { selector: string; createElementMetadata: CreateElementMetadataCallback; compareElementMetadata: CompareElementMetadataCallback; @@ -47,7 +47,7 @@ export type ConstructorDetails = { onError?: OnErrorCallback | null; }; -export type ElementObserver = { +export type ElementObserver = { element: Element; type: NormalizedElementType; value: unknown; @@ -70,17 +70,17 @@ export type AssignTaskValue = {value: ValueType}; export type ValueType = boolean | string | number | null; -export type UpdateTask = [ +export type UpdateTask = [ key: ElementObserver | null, task: TaskAccumulator.Task, ]; -export type AssignTask = [ +export type AssignTask = [ key: ElementObserver | null, task: TaskAccumulator.Task, ]; -export type ApplyTarget = [ +export type ApplyTarget = [ observer: ElementObserver, task: TaskAccumulator.Task | TaskAccumulator.Task | null, ]; diff --git a/types/ext/dynamic-property.d.ts b/types/ext/dynamic-property.d.ts index 5ec886d2..ba15257a 100644 --- a/types/ext/dynamic-property.d.ts +++ b/types/ext/dynamic-property.d.ts @@ -17,6 +17,6 @@ export type EventType = 'change'; -export type ChangeEventDetails = { +export type ChangeEventDetails = { value: T; }; diff --git a/types/ext/selector-observer.d.ts b/types/ext/selector-observer.d.ts index a84b2add..2b3e9381 100644 --- a/types/ext/selector-observer.d.ts +++ b/types/ext/selector-observer.d.ts @@ -15,15 +15,15 @@ * along with this program. If not, see . */ -export type OnAddedCallback = (element: Element) => T | undefined; +export type OnAddedCallback = (element: Element) => T | undefined; -export type OnRemovedCallback = (element: Element, data: T) => void; +export type OnRemovedCallback = (element: Element, data: T) => void; -export type OnChildrenUpdatedCallback = (element: Element, data: T) => void; +export type OnChildrenUpdatedCallback = (element: Element, data: T) => void; -export type IsStaleCallback = (element: Element, data: T) => boolean; +export type IsStaleCallback = (element: Element, data: T) => boolean; -export type ConstructorDetails = { +export type ConstructorDetails = { /** A string CSS selector used to find elements. */ selector: string; /** A string CSS selector used to filter elements, or `null` for no filtering. */ @@ -48,7 +48,7 @@ export type MutationRecordLike = { target: Node; }; -export type Observer = { +export type Observer = { element: Element; ancestors: Node[]; data: T; diff --git a/types/ext/task-accumulator.d.ts b/types/ext/task-accumulator.d.ts index f02d449b..e96ba6a6 100644 --- a/types/ext/task-accumulator.d.ts +++ b/types/ext/task-accumulator.d.ts @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -export type Task = { +export type Task = { data: V; stale: boolean; }; -- cgit v1.2.3