Skip to content
Latchkey

NestJS "Cannot determine a type for the X property" in CI

class-transformer could not infer the runtime type of a nested property because design-time type metadata for it is missing. Nest needs an explicit @Type() or the metadata plugin to know how to transform it.

What this error means

Validation or serialization fails with "Cannot determine a type for the X property (05)" for a nested DTO or array property when using ValidationPipe or plainToInstance.

NestJS
Error: Cannot determine a type for the "items" property (405). Make sure your property
is decorated with a "@Type()" decorator, or supply a corresponding class.

Common causes

A nested object or array has no @Type()

class-transformer cannot see the element class of an array or nested object from the emitted metadata alone, so it needs an explicit @Type().

The mapped types metadata plugin is not enabled

Without the Nest CLI type metadata plugin, generic wrappers like arrays lose their element type at runtime.

How to fix it

Annotate the nested type with @Type()

  1. Import Type from class-transformer.
  2. Decorate the nested property with @Type(() => ChildDto).
  3. Re-run validation so the transformer knows the target class.
order.dto.ts
class OrderDto {
  @ValidateNested({ each: true })
  @Type(() => ItemDto)
  items: ItemDto[];
}

Enable the CLI metadata plugin

The Nest CLI plugin injects the missing type metadata automatically for DTOs.

nest-cli.json
{ "compilerOptions": { "plugins": ["@nestjs/swagger"] } }

How to prevent it

  • Add @Type() to every nested and array DTO property.
  • Enable the Nest CLI metadata plugin for consistent transformation.
  • Cover DTO validation with tests so missing types fail in CI.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →