Home > @imqueue/rpc > classType

classType() function

Implements the '@classType' decorator factory.

Applied to a complex-type class, it registers the class's '@property' field definitions into the RPC type description so the type can be exposed to service clients. It is required on any class that uses '@property': standard (TC39) field decorators cannot see the class they belong to, so a class-level decorator is needed to flush the collected properties under the class name.

Signature:

export declare function classType(): any;

Returns:

any

Example

~~~typescript import { classType, property, expose, IMQService } from '@imqueue/rpc';

@classType() class Address { @property('string') country: string;

@property('string', true) zipCode?: string; // optional }

@classType() class User { @property('string') firstName: string;

@property('Array

', true) addresses?: Address[]; }

class UserService extends IMQService { @expose() public save(user: User) { // now User (and Address) are properly exposed to clients } } ~~~

{(value: Function, context: ClassDecoratorContext) => void}