Skip to content

Commit

Permalink
typing: avoid key any
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Dec 1, 2023
1 parent 175c3d8 commit 15aee99
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/cachers/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ declare namespace Cacher {
keygen?: CacherKeygen;
maxParamsLength?: number;
missingResponse?: any;
[key: string]: any;
// [key: string]: any;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/context.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ declare namespace Context {
handler?: ActionHandler;
context?: boolean;

[key: string]: any;
// [key: string]: any;
}

export interface ContextParentSpan {
Expand Down
2 changes: 1 addition & 1 deletion src/errors.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export declare class InvalidPacketDataError extends MoleculerError {
interface PlainMoleculerError extends MoleculerError {
nodeID?: string;

[key: string]: any;
// [key: string]: any;
}

export declare class Regenerator {
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/types/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ declare namespace BaseMetric {
labelNames?: string[];
unit?: string;
aggregator?: string;
[key: string]: unknown;
// [key: string]: unknown;
}

export interface BaseMetricPOJO<TSnapshot extends Record<string, any>> {
Expand Down
2 changes: 0 additions & 2 deletions src/registry/discoverers/local.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ declare namespace LocalDiscoverer {
}

declare class LocalDiscoverer extends BaseDiscoverer {
opts: LocalDiscoverer.LocalDiscovererOptions;

constructor(opts?: LocalDiscoverer.LocalDiscovererOptions);
init(registry: Registry): void;
discoverNode(nodeID: string): Promise<void>;
Expand Down
2 changes: 1 addition & 1 deletion src/registry/node.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ declare class Node {
hostname: string | null;
udpAddress: string | null;

rawInfo: Record<string, any> | null;
rawInfo: NodeRawInfo | null;
services: Record<string, any>[];

cpu: number | null;
Expand Down
13 changes: 7 additions & 6 deletions src/registry/registry.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { ActionCatalogListOptions } from "./action-catalog";
import type { Logger } from "../logger-factory";
import type { BrokerRegistryOptions } from "../service-broker";
import type { ActionSchema, ServiceEvent } from "../service";
import ServiceItem = require("./service-item");
import ServiceCatalog = require("./service-catalog");
import ActionCatalog = require("./action-catalog");
import ActionEndpoint = require("./endpoint-action");
Expand Down Expand Up @@ -56,7 +57,7 @@ declare class ServiceRegistry {

checkActionVisibility(action: ActionSchema, node: Node): boolean;

registerActions(node: Node, service: Service, actions: Record<string, ActionSchema>): void;
registerActions(node: Node, service: ServiceItem, actions: Record<string, ActionSchema>): void;

createPrivateActionEndpoint(action: ActionSchema): ActionEndpoint;

Expand All @@ -70,7 +71,7 @@ declare class ServiceRegistry {
unregisterServicesByNode(nodeID: string): void;
unregisterAction(node: Node, actionName: string): void;

registerEvents(node: Node, service: Service, events: Record<string, ServiceEvent>): void;
registerEvents(node: Node, service: ServiceItem, events: Record<string, ServiceEvent>): void;
unregisterEvent(node: Node, eventName: string): void;

regenerateLocalRawInfo(incSeq: boolean, isStopping?: boolean): ServiceRegistry.NodeRawInfo;
Expand All @@ -79,10 +80,10 @@ declare class ServiceRegistry {
getNodeInfo(nodeID: string): ServiceRegistry.NodeRawInfo;
processNodeInfo(payload: any): any;

getNodeList(opts?: ActionCatalogListOptions): Promise<ReturnType<NodeCatalog["list"]>>;
getServiceList(opts?: ActionCatalogListOptions): Promise<ReturnType<ServiceCatalog["list"]>>;
getActionList(opts?: ActionCatalogListOptions): Promise<ReturnType<ActionCatalog["list"]>>;
getEventList(opts?: ActionCatalogListOptions): Promise<ReturnType<EventCatalog["list"]>>;
getNodeList(opts?: ActionCatalogListOptions): ReturnType<NodeCatalog["list"]>;
getServiceList(opts?: ActionCatalogListOptions): ReturnType<ServiceCatalog["list"]>;
getActionList(opts?: ActionCatalogListOptions): ReturnType<ActionCatalog["list"]>;
getEventList(opts?: ActionCatalogListOptions): ReturnType<EventCatalog["list"]>;

getNodeRawList(): Array<ServiceRegistry.NodeRawInfo>;
}
Expand Down
7 changes: 4 additions & 3 deletions src/registry/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const { METRIC } = require("../metrics");
*
* @typedef {import("../context")} Context
* @typedef {import("../service")} Service
* @typedef {import("./service-item")} ServiceItem
* @typedef {import("../service").ServiceAction} ServiceAction
* @typedef {import("../service").ActionSchema} ActionSchema
* @typedef {import("../service").ServiceEvent} ServiceEvent
Expand Down Expand Up @@ -310,7 +311,7 @@ class Registry {
* Register service actions
*
* @param {Node} node
* @param {Service} service
* @param {ServiceItem} service
* @param {Record<string, ActionSchema>} actions
* @memberof Registry
*/
Expand Down Expand Up @@ -438,7 +439,7 @@ class Registry {
* Register service events
*
* @param {Node} node
* @param {Service} service
* @param {ServiceItem} service
* @param {Record<string, ServiceEvent>} events
* @memberof Registry
*/
Expand Down Expand Up @@ -471,7 +472,7 @@ class Registry {
* Generate local raw info for INFO packet
*
* @param {boolean} incSeq
* @param {boolean?} isStopping
* @param {boolean=} isStopping
*
* @returns {NodeRawInfo}
* @memberof Registry
Expand Down
2 changes: 0 additions & 2 deletions src/service-broker.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,6 @@ declare class ServiceBroker {
getEventListeners(eventName: string): EventEndpoint[];

getConstructorName(obj: any): string;

[key: string]: any;
}

export = ServiceBroker;
12 changes: 6 additions & 6 deletions src/service.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ declare namespace Service {

export type ActionVisibility = "published" | "public" | "protected" | "private";

export type ActionParamSchema = { [key: string]: any };
// export type ActionParamSchema = { [key: string]: any };
export type ActionParamTypes =
| "any"
| "array"
Expand All @@ -83,8 +83,8 @@ declare namespace Service {
| "url"
| "uuid"
| boolean
| string
| ActionParamSchema;
| string;
// | ActionParamSchema;
export type ActionParams = { [key: string]: ActionParamTypes };

export type ActionCacheEnabledFunc = (ctx: Context<any, any>) => boolean;
Expand Down Expand Up @@ -115,7 +115,7 @@ declare namespace Service {
strategy?: string| typeof Strategy;
strategyOptions?: Record<string, any>;

[key: string]: any;
// [key: string]: any;
}

export type ActionHandler<T = any> = (ctx: Context<any, any>) => Promise<T> | T;
Expand Down Expand Up @@ -179,7 +179,7 @@ declare namespace Service {
strategyOptions?: Record<string, any>;
handler?: ServiceEventHandler | ServiceEventLegacyHandler;

[key: string]: any;
// [key: string]: any;
}

export type ServiceEvents<S = ServiceSettingSchema> = {
Expand Down Expand Up @@ -254,7 +254,7 @@ declare class Service<S = Service.ServiceSettingSchema> {
interval?: number
): Promise<Service.WaitForServicesResult>;

[key: string]: any;
// [key: string]: any;

/**
* Apply `mixins` list in schema. Merge the schema with mixins schemas. Returns with the mixed schema
Expand Down

0 comments on commit 15aee99

Please sign in to comment.