JohnWeisz/TypedJSON

Using @json[Array,Set,Map]Member with a nullable type does not work

Closed this issue · 0 comments

Example:

@jsonObject
export class NullableArray {

    @jsonArrayMember(String)
    arrayNullable: Array<string> | null;
}

results in @jsonArrayMember on NullableArray.arrayNullable: property is not an Array. Make sure that you have both "experimentalDecorators" and "emitDecoratorMetadata" enabled in your tsconfig.json.

This is because the reflected type is Object and not Array when strictNullChecks are enabled in tsconfig.json.

Repository to test the difference strictNullChecks makes: https://github.com/MatthiasKunnen/reflect-metadata-strict-null-checks