From 5cfe479044e3d893876d25c263503fce0d3134a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Fri, 14 Nov 2025 22:24:50 +0800 Subject: [PATCH] Refactor createListenerFunction type and usage Simplifies the generic type signature of createListenerFunction and updates the way createEventFunction is called, removing unnecessary type parameters and using a direct function call with TypeScript ignore for type checking. --- packages/napcat-common/src/event.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/napcat-common/src/event.ts b/packages/napcat-common/src/event.ts index 705d5b79..308229e8 100644 --- a/packages/napcat-common/src/event.ts +++ b/packages/napcat-common/src/event.ts @@ -78,18 +78,15 @@ export class NTEventWrapper { return undefined; } - createListenerFunction>(listenerMainName: string, uniqueCode: string = ''): T { + createListenerFunction (listenerMainName: string, uniqueCode: string = ''): T { const existListener = this.listenerManager.get(listenerMainName + uniqueCode); if (!existListener) { const Listener = this.createProxyDispatch(listenerMainName); const ServiceSubName = /^NodeIKernel(.*?)Listener$/.exec(listenerMainName)![1]; - const Service = `NodeIKernel${ServiceSubName}Service/addKernel${ServiceSubName}Listener` as `${Listener}/${ListenerMethod}`; - this.createEventFunction< - keyof ServiceNamingMapping, - FuncKeys, - (...args: any[]) => any - >(Service as `${keyof ServiceNamingMapping}/${FuncKeys}`); + const Service = `NodeIKernel${ServiceSubName}Service/addKernel${ServiceSubName}Listener`; + + // @ts-ignore + this.createEventFunction(Service)(Listener as T); this.listenerManager.set(listenerMainName + uniqueCode, Listener); return Listener as T; }