aboutsummaryrefslogtreecommitdiff
path: root/types
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-12-19 01:17:22 -0500
committerGitHub <noreply@github.com>2023-12-19 06:17:22 +0000
commite9e504b40dde8691c32c933c7e27e28cfad1c8b5 (patch)
tree1128f311d9e5cb6316fbf237724eb2b87a522446 /types
parent20dd6112724a77fee16281930e79a2e6822acff7 (diff)
Template type improvements (#380)
* Default templates to unknown * Default typescript templates to unknown * More template type updates
Diffstat (limited to 'types')
-rw-r--r--types/ext/anki-templates-internal.d.ts2
-rw-r--r--types/ext/api.d.ts2
-rw-r--r--types/ext/cache-map.d.ts2
-rw-r--r--types/ext/core.d.ts2
-rw-r--r--types/ext/dictionary-data-util.d.ts2
-rw-r--r--types/ext/dictionary-database.d.ts6
-rw-r--r--types/ext/dictionary-worker.d.ts6
-rw-r--r--types/ext/dom-data-binder.d.ts24
-rw-r--r--types/ext/dynamic-property.d.ts2
-rw-r--r--types/ext/selector-observer.d.ts12
-rw-r--r--types/ext/task-accumulator.d.ts2
11 files changed, 31 insertions, 31 deletions
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<T> = {
+export type CachedValue<T = unknown> = {
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<TDetails, TResult, THasSender extends boolean = false> = (
+export type Handler<TDetails = unknown, TResult = unknown, THasSender extends boolean = false> = (
details: TDetails,
sender: (THasSender extends true ? chrome.runtime.MessageSender : void)
) => (TResult | Promise<TResult>);
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 <https://www.gnu.org/licenses/>.
*/
-export type Node<K, V> = {
+export type Node<K = unknown, V = unknown> = {
key: K | null;
value: V | null;
previous: Node<K, V> | 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<string, never>;
-export type DeferredPromiseDetails<T> = {
+export type DeferredPromiseDetails<T = unknown> = {
promise: Promise<T>;
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<string, FrequencyData>;
-export type DictionaryFrequency<T> = {
+export type DictionaryFrequency<T = unknown> = {
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<TItem = unknown> = {
indexIndex: number;
};
-export type CreateQuery<TItem> = (item: TItem) => (IDBValidKey | IDBKeyRange | null);
+export type CreateQuery<TItem = unknown> = (item: TItem) => (IDBValidKey | IDBKeyRange | null);
-export type FindPredicate<TItem, TRow> = (row: TRow, item: TItem) => boolean;
+export type FindPredicate<TItem = unknown, TRow = unknown> = (row: TRow, item: TItem) => boolean;
-export type CreateResult<TItem, TRow, TResult> = (row: TRow, data: FindMultiBulkData<TItem>) => TResult;
+export type CreateResult<TItem = unknown, TRow = unknown, TResult = unknown> = (row: TRow, data: FindMultiBulkData<TItem>) => 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<TResponseRaw = unknown, TResponse = unknown> = {
formatResult: ((result: TResponseRaw) => TResponse) | null;
};
-export type MessageCompleteData<TResponseRaw> = {
+export type MessageCompleteData<TResponseRaw = unknown> = {
action: 'complete';
params: MessageCompleteParams<TResponseRaw>;
};
@@ -44,7 +44,7 @@ export type MessageGetImageDetailsData = {
params: MessageGetImageDetailsParams;
};
-export type MessageCompleteParams<TResponseRaw> = Core.Response<TResponseRaw>;
+export type MessageCompleteParams<TResponseRaw = unknown> = Core.Response<TResponseRaw>;
export type MessageProgressParams = {
args: unknown[];
@@ -56,7 +56,7 @@ export type MessageGetImageDetailsParams = {
mediaType: string;
};
-export type MessageData<TResponseRaw> = MessageCompleteData<TResponseRaw> | MessageProgressData | MessageGetImageDetailsData;
+export type MessageData<TResponseRaw = unknown> = MessageCompleteData<TResponseRaw> | 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<T> = (element: Element) => T | undefined;
+export type CreateElementMetadataCallback<T = unknown> = (element: Element) => T | undefined;
-export type CompareElementMetadataCallback<T> = (metadata1: T, metadata2: T) => boolean;
+export type CompareElementMetadataCallback<T = unknown> = (metadata1: T, metadata2: T) => boolean;
-export type GetValuesCallback<T> = (args: GetValuesDetails<T>[]) => Promise<TaskResult[]>;
+export type GetValuesCallback<T = unknown> = (args: GetValuesDetails<T>[]) => Promise<TaskResult[]>;
-export type SetValuesCallback<T> = (args: SetValuesDetails<T>[]) => Promise<TaskResult[]>;
+export type SetValuesCallback<T = unknown> = (args: SetValuesDetails<T>[]) => Promise<TaskResult[]>;
-export type GetValuesDetails<T> = {
+export type GetValuesDetails<T = unknown> = {
element: Element;
metadata: T;
};
-export type SetValuesDetails<T> = {
+export type SetValuesDetails<T = unknown> = {
element: Element;
metadata: T;
value: ValueType;
};
-export type OnErrorCallback<T> = (error: Error, stale: boolean, element: Element, metadata: T) => void;
+export type OnErrorCallback<T = unknown> = (error: Error, stale: boolean, element: Element, metadata: T) => void;
-export type ConstructorDetails<T> = {
+export type ConstructorDetails<T = unknown> = {
selector: string;
createElementMetadata: CreateElementMetadataCallback<T>;
compareElementMetadata: CompareElementMetadataCallback<T>;
@@ -47,7 +47,7 @@ export type ConstructorDetails<T> = {
onError?: OnErrorCallback<T> | null;
};
-export type ElementObserver<T> = {
+export type ElementObserver<T = unknown> = {
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<T> = [
+export type UpdateTask<T = unknown> = [
key: ElementObserver<T> | null,
task: TaskAccumulator.Task<UpdateTaskValue>,
];
-export type AssignTask<T> = [
+export type AssignTask<T = unknown> = [
key: ElementObserver<T> | null,
task: TaskAccumulator.Task<AssignTaskValue>,
];
-export type ApplyTarget<T> = [
+export type ApplyTarget<T = unknown> = [
observer: ElementObserver<T>,
task: TaskAccumulator.Task<UpdateTaskValue> | TaskAccumulator.Task<AssignTaskValue> | 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<T> = {
+export type ChangeEventDetails<T = unknown> = {
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 <https://www.gnu.org/licenses/>.
*/
-export type OnAddedCallback<T> = (element: Element) => T | undefined;
+export type OnAddedCallback<T = unknown> = (element: Element) => T | undefined;
-export type OnRemovedCallback<T> = (element: Element, data: T) => void;
+export type OnRemovedCallback<T = unknown> = (element: Element, data: T) => void;
-export type OnChildrenUpdatedCallback<T> = (element: Element, data: T) => void;
+export type OnChildrenUpdatedCallback<T = unknown> = (element: Element, data: T) => void;
-export type IsStaleCallback<T> = (element: Element, data: T) => boolean;
+export type IsStaleCallback<T = unknown> = (element: Element, data: T) => boolean;
-export type ConstructorDetails<T> = {
+export type ConstructorDetails<T = unknown> = {
/** 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<T> = {
+export type Observer<T = unknown> = {
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 <https://www.gnu.org/licenses/>.
*/
-export type Task<V> = {
+export type Task<V = unknown> = {
data: V;
stale: boolean;
};