Skip to content

Commit a1b96f7

Browse files
committed
And some more with some weird types
1 parent d0a71cd commit a1b96f7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/index/datacore.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,18 +258,18 @@ export class Datacore extends Component {
258258
///////////////////////
259259

260260
/** Called whenever the index updates to a new revision. This is the broadest possible datacore event. */
261-
public on(evt: "update", callback: (revision: number) => void, context?: any): EventRef;
261+
public on(evt: "update", callback: (revision: number) => void, context?: unknown): EventRef;
262262
/** Called whenever datacore records a file rename and has finished reindexing the rename. */
263-
public on(evt: "rename", callback: (newPath: string, oldPath: string) => void, context?: any): EventRef;
263+
public on(evt: "rename", callback: (newPath: string, oldPath: string) => void, context?: unknown): EventRef;
264264
/** Called when datacore has initialized and is querable. */
265-
public on(evt: "initialized", callback: () => void, context?: any): EventRef;
265+
public on(evt: "initialized", callback: () => void, context?: unknown): EventRef;
266266

267-
on(evt: string, callback: (...data: any[]) => void, context?: any): EventRef {
268-
return this.events.on(evt, callback, context);
267+
on<T extends Function>(evt: string, callback: T, context?: unknown): EventRef {
268+
return this.events.on(evt, callback as unknown as (...args: unknown[]) => unknown, context);
269269
}
270270

271271
/** Unsubscribe from an event using the event and original callback. */
272-
off(evt: string, callback: (...data: any[]) => void) {
272+
off(evt: string, callback: (...data: unknown[]) => void) {
273273
this.events.off(evt, callback);
274274
}
275275

@@ -286,7 +286,7 @@ export class Datacore extends Component {
286286
private trigger(evt: "initialized"): void;
287287

288288
/** Trigger an event. */
289-
private trigger(evt: string, ...args: any[]): void {
289+
private trigger(evt: string, ...args: unknown[]): void {
290290
this.events.trigger(evt, ...args);
291291
}
292292
}

0 commit comments

Comments
 (0)