From 5452eb757574821d4bf5a4a09964f9c4cdb82afe Mon Sep 17 00:00:00 2001 From: OspinaOcampo <56151794+OspinaOcampo@users.noreply.github.com> Date: Tue, 10 Jan 2023 16:47:01 +0100 Subject: [PATCH 1/2] Update index.ts Fix issue "Support for angular 9" (https://github.com/jf3096/json-typescript-mapper/issues/46) --- index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index bded66b..5105b6a 100644 --- a/index.ts +++ b/index.ts @@ -184,9 +184,9 @@ export function deserialize(Clazz: {new(): T}, json: I * pass value to instance */ if (decoratorMetaData && decoratorMetaData.customConverter) { - instance[key] = decoratorMetaData.customConverter.fromJson(json[decoratorMetaData.name || key]); + instance[key as keyof T] = decoratorMetaData.customConverter.fromJson(json[decoratorMetaData.name || key]); } else { - instance[key] = decoratorMetaData ? mapFromJson(decoratorMetaData, instance, json, key) : json[key]; + instance[key as keyof T] = decoratorMetaData ? mapFromJson(decoratorMetaData, instance, json, key) : json[key]; } }); From 2fc6d318d997890ebed9114fd9994bb8d0e9e740 Mon Sep 17 00:00:00 2001 From: OspinaOcampo <56151794+OspinaOcampo@users.noreply.github.com> Date: Wed, 11 Jan 2023 18:15:50 +0100 Subject: [PATCH 2/2] Update index.ts --- index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.ts b/index.ts index 5105b6a..e5f635b 100644 --- a/index.ts +++ b/index.ts @@ -172,7 +172,7 @@ export function deserialize(Clazz: {new(): T}, json: I /** * init root class to contain json */ - let instance: IGenericObject = new Clazz(); + let instance = new Clazz(); Object.keys(instance).forEach((key: string) => { /** @@ -184,14 +184,14 @@ export function deserialize(Clazz: {new(): T}, json: I * pass value to instance */ if (decoratorMetaData && decoratorMetaData.customConverter) { - instance[key as keyof T] = decoratorMetaData.customConverter.fromJson(json[decoratorMetaData.name || key]); + instance[key as keyof T] = decoratorMetaData.customConverter.fromJson(json[decoratorMetaData.name || key]); } else { instance[key as keyof T] = decoratorMetaData ? mapFromJson(decoratorMetaData, instance, json, key) : json[key]; } }); - return instance as T; + return instance; } /**