# PropertyType Decorator

Module
import { PropertyType } from "@tsed/common"
Source/packages/common/src/jsonschema/decorators/propertyType.ts

# Overview

function PropertyType(type: Type<any>): Function;

# Description

Set the type of the array items. The possible value is String, Boolean, Number, Date, Object, Class, etc...

TIP

This decorator is used by the Converters to correctly deserialize your model.

class Model {
   @PropertyType(String)
   property: string[];
}
1
2
3
4

WARNING

Don't use type Type = string | number as Type parameter.

The following code doesn't work:

type Type = "string" | "number"
class Model {
   @PropertyType(Type)
   property: Type[];
}
1
2
3
4
5

Instead, this code works with converter and AJV:

type Type = "string" | "number"
class Model {
   @Property()
   @AllowTypes("string", "number") // for AJV
   property: Type[];
}
1
2
3
4
5
6

:::