# classType() function · @imqueue/rpc

Source: https://imqueue.org/api/rpc/latest/rpc.classtype/
Published: 2026-08-04
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/rpc 3.5.3 — generated reference, not hand-written

Registers a complex-type class's `@property` field definitions into the RPC type description, so the type can be exposed to service clients.

**Signature:**

```typescript
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()](https://imqueue.org/api/rpc/latest/rpc.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()](https://imqueue.org/api/rpc/latest/rpc.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()](https://imqueue.org/api/rpc/latest/rpc.indexed/) performs the same flush in addition to recording an index signature, so a class carrying `@indexed()` does not also need `@classType()`.

## 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(() => [Address], true)
    addresses?: Address[];
}

class UserService extends IMQService {
    @expose()
    public save(user: User) {
        // now User (and Address) are properly exposed to clients
    }
}
```

