Skip to content

Commit

Permalink
Default typescript templates to unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
toasted-nutbread committed Dec 19, 2023
1 parent 7896ca5 commit e838cdc
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion types/ext/anki-templates-internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion types/ext/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>);
Expand Down
2 changes: 1 addition & 1 deletion types/ext/cache-map.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion types/ext/core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion types/ext/dictionary-data-util.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
};
Expand Down
6 changes: 3 additions & 3 deletions types/ext/dictionary-database.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions types/ext/dictionary-worker.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
};
Expand All @@ -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[];
Expand All @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions types/ext/dom-data-binder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion types/ext/dynamic-property.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@

export type EventType = 'change';

export type ChangeEventDetails<T> = {
export type ChangeEventDetails<T = unknown> = {
value: T;
};
12 changes: 6 additions & 6 deletions types/ext/selector-observer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -48,7 +48,7 @@ export type MutationRecordLike = {
target: Node;
};

export type Observer<T> = {
export type Observer<T = unknown> = {
element: Element;
ancestors: Node[];
data: T;
Expand Down
2 changes: 1 addition & 1 deletion types/ext/task-accumulator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

0 comments on commit e838cdc

Please sign in to comment.