# ClassSerializerContextOptions

**Kind:** Interface

**Source:** [`packages/common/serializer/class-serializer.interfaces.ts`](https://github.com/nestjs/nest/blob/master/packages/common/serializer/class-serializer.interfaces.ts#L7)

**Part of:** [Common](subsystem-packages-common)

`ClassSerializerContextOptions` provides serializer context metadata for class-based transformation operations. Its `type` field identifies the target constructor, allowing the serializer to resolve class-specific serialization behavior and metadata.

## Properties

| Property | Type |
|---|---|
| `type` | `Type<any>` |

## Diagram

```mermaid
graph LR
  A[Serialization Request] --> B[ClassSerializerContextOptions]
  B --> C[type: Type<any>]
  C --> D[Target Class Constructor]
  D --> E[Class Serialization Metadata]
  E --> F[Serialized Output]
```

## Usage

```ts
import { ClassSerializerContextOptions, Type } from '@nestjs/common';

class UserDto {
  id: number;
  email: string;
}

const serializerOptions: ClassSerializerContextOptions = {
  type: UserDto as Type<UserDto>,
};

// Pass the options to serializer-related infrastructure
function serializeWithContext(options: ClassSerializerContextOptions) {
  return options.type;
}

const targetType = serializeWithContext(serializerOptions);
```

## AI Coding Instructions

- Set `type` to the constructor of the class whose serialization metadata should be used.
- Use Nest's `Type<T>` type when declaring or passing class constructors.
- Do not pass an instance (for example, `new UserDto()`); provide the class reference (`UserDto`) instead.
- Integrate this interface where serializer logic needs explicit target-type information, especially when runtime type inference is unavailable.
