# PropertyType Decorator jsonMapper schema property collections deprecated

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...

WARNING

This decorator will be removed in v6 in favor of from @tsed/schema. For v5 user, use decorator from @tsed/common then in v6 switch to @tsed/schema.

TIP

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

class Model {
   @CollectionOf(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 {
   @CollectionOf(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