From 978c83bf0169db04c0ad09bcb5e489fc4e16dd1d Mon Sep 17 00:00:00 2001 From: Luuk van Houdt <71889608+luukvhoudt@users.noreply.github.com> Date: Tue, 7 Feb 2023 22:37:28 +0100 Subject: [PATCH] add type interference to plainToClass --- src/index.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index 3bef5422b..1a42973ee 100644 --- a/src/index.ts +++ b/src/index.ts @@ -65,20 +65,20 @@ export function classToPlainFromExist( * * @deprecated Function name changed, use the `plainToInstance` method instead. */ -export function plainToClass(cls: ClassConstructor, plain: V[], options?: ClassTransformOptions): T[]; -export function plainToClass(cls: ClassConstructor, plain: V, options?: ClassTransformOptions): T; -export function plainToClass(cls: ClassConstructor, plain: V | V[], options?: ClassTransformOptions): T | T[] { +export function plainToClass(cls: ClassConstructor, plain: T[], options?: ClassTransformOptions): T[]; +export function plainToClass(cls: ClassConstructor, plain: T, options?: ClassTransformOptions): T; +export function plainToClass(cls: ClassConstructor, plain: T | T[], options?: ClassTransformOptions): T | T[] { return classTransformer.plainToInstance(cls, plain as any, options); } /** * Converts plain (literal) object to class (constructor) object. Also works with arrays. */ -export function plainToInstance(cls: ClassConstructor, plain: V[], options?: ClassTransformOptions): T[]; -export function plainToInstance(cls: ClassConstructor, plain: V, options?: ClassTransformOptions): T; -export function plainToInstance( +export function plainToInstance(cls: ClassConstructor, plain: T[], options?: ClassTransformOptions): T[]; +export function plainToInstance(cls: ClassConstructor, plain: T, options?: ClassTransformOptions): T; +export function plainToInstance( cls: ClassConstructor, - plain: V | V[], + plain: T | T[], options?: ClassTransformOptions ): T | T[] { return classTransformer.plainToInstance(cls, plain as any, options);