Fix ArrayType: support null or undefined values.

This commit is contained in:
Madeorsk 2022-10-16 01:20:25 +02:00
parent c1b8e8adb1
commit cfbf74911b

View File

@ -16,6 +16,9 @@ export class ArrayType<SerializedValueType, SharkitekValueType> extends Type<Ser
serialize(value: SharkitekValueType[]): SerializedValueType[] serialize(value: SharkitekValueType[]): SerializedValueType[]
{ {
if (value === undefined) return undefined;
if (value === null) return null;
return value.map((value) => ( return value.map((value) => (
// Serializing each value of the array. // Serializing each value of the array.
this.valueType.serialize(value) this.valueType.serialize(value)
@ -24,6 +27,9 @@ export class ArrayType<SerializedValueType, SharkitekValueType> extends Type<Ser
deserialize(value: SerializedValueType[]): SharkitekValueType[] deserialize(value: SerializedValueType[]): SharkitekValueType[]
{ {
if (value === undefined) return undefined;
if (value === null) return null;
return value.map((serializedValue) => ( return value.map((serializedValue) => (
// Deserializing each value of the array. // Deserializing each value of the array.
this.valueType.deserialize(serializedValue) this.valueType.deserialize(serializedValue)