classType() function

Registers a complex-type class's @property field definitions into the RPC type description, so the type can be exposed to service clients.

Signature:

export declare function classType(): any;

Returns:

any

a dual-mode class decorator (value, context?) => any, typed any so one function serves both decorator protocols. Under standard (TC39) decorators it flushes the collected fields via registerType() and returns undefined; under legacy decorators it is a pass-through that returns the class unchanged.

Remarks

Required on every class that uses property() when compiling with standard (TC39) decorators, the protocol this package targets: standard field decorators cannot see their class, so a class-level decorator is what flushes the collected fields under the class name.

Under legacy (experimentalDecorators) decorators @property registers each field directly and this decorator is a harmless no-op.

Omitting it produces no error — the type is silently missing from the RPC type description, and generated clients then reference an undeclared type. Applying it to a class with no @property fields registers an empty type description.

indexed() performs the same flush in addition to recording an index signature, so a class carrying @indexed() does not also need @classType().

Example

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(() => [Address], true)
    addresses?: Address[];
}

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

Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.