From 50f21f96fc4c403838abe39368cb4df6ff087003 Mon Sep 17 00:00:00 2001 From: marcus-sa Date: Mon, 30 Oct 2023 22:29:04 +0100 Subject: [PATCH] feat(rpc): add support for class typeName in rpc class decorator --- packages/rpc/src/decorators.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/rpc/src/decorators.ts b/packages/rpc/src/decorators.ts index 0591bde06..173ba91ad 100644 --- a/packages/rpc/src/decorators.ts +++ b/packages/rpc/src/decorators.ts @@ -9,12 +9,19 @@ */ import { ClassType } from '@deepkit/core'; -import { ClassDecoratorResult, createClassDecoratorContext, createPropertyDecoratorContext, mergeDecorator, PropertyDecoratorResult } from '@deepkit/type'; +import { + ClassDecoratorResult, + createClassDecoratorContext, + createPropertyDecoratorContext, + mergeDecorator, + PropertyDecoratorResult, + reflect +} from '@deepkit/type'; import { ControllerDefinition } from './model.js'; class RpcController { // Defaults to the name of the class - name!: string; + name: string = ''; definition?: ControllerDefinition; @@ -52,7 +59,7 @@ class RpcClass { } onDecorator(classType: ClassType) { - this.t.name ??= classType.name; + this.t.name ??= reflect(classType).typeName || classType.name; } }