Adjust NodeJS.Timout type usage (#5026)

This commit is contained in:
Jaco
2022-07-04 16:15:50 +03:00
committed by GitHub
parent 637cc089fe
commit 75bbd042a9
4 changed files with 19 additions and 6 deletions
+7
View File
@@ -1,5 +1,12 @@
# CHANGELOG
## master
Changes:
- Adjust type signatures for non-required use of `@types/node`
## 8.11.2 Jul 4, 2022
Changes:
+4 -2
View File
@@ -29,7 +29,8 @@ function textToString (t: Text): string {
}
export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
#healthTimer: NodeJS.Timeout | null = null;
// Browser/Deno = number, Node = Timeout
#healthTimer: unknown | null = null;
#registries: VersionedRegistry<ApiType>[] = [];
@@ -369,7 +370,8 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
private _unsubscribeHealth (): void {
if (this.#healthTimer) {
clearInterval(this.#healthTimer);
// different method signatures for Node vs Browser/Deno
clearInterval(this.#healthTimer as number);
this.#healthTimer = null;
}
}
+4 -2
View File
@@ -44,7 +44,8 @@ export class MockProvider implements ProviderInterface {
private emitter = new EventEmitter();
private intervalId?: NodeJS.Timeout | null;
// Browser/Deno = number, Node = Timeout
private intervalId?: unknown | null;
public isUpdating = true;
@@ -109,7 +110,8 @@ export class MockProvider implements ProviderInterface {
// eslint-disable-next-line @typescript-eslint/require-await
public async disconnect (): Promise<void> {
if (this.intervalId) {
clearInterval(this.intervalId);
// different method signatures for Node vs Browser/Deno
clearInterval(this.intervalId as number);
this.intervalId = null;
}
}
+4 -2
View File
@@ -106,7 +106,8 @@ export class WsProvider implements ProviderInterface {
#subscriptions: Record<string, WsStateSubscription> = {};
#timeoutId?: NodeJS.Timeout | null = null;
// Browser/Deno = number, Node = Timeout
#timeoutId?: unknown | null = null;
#websocket: WebSocket | null;
@@ -426,7 +427,8 @@ export class WsProvider implements ProviderInterface {
}
if (this.#timeoutId) {
clearInterval(this.#timeoutId);
// different method signatures for Node vs Browser/Deno
clearInterval(this.#timeoutId as number);
this.#timeoutId = null;
}