Skip to content

Using JsonCustomConverter causes Expected type to be undefined #75

Open
@fider

Description

@fider

Example:

@JsonConverter
class StringConverter implements JsonCustomConvert<string> {
    serialize(data: Data): any {return "..."}

    deserialize(str: any): Data {
        if ( ! isValid( str ) ) {
          throw new Error(`Invalid value is ${str}`);
        }
        return str;
    }
}

class Data {
    @JsonProperty("name", StringConverter )
    public name: string = undefined as any;
}

let data = { name: "invalid_name" }
jsonConvert.deserialize(data, Data);

Will thorw error message:

`
        Class property:
                name

        Expected type:
                undefined

        JSON property:
                name

        JSON type:
                string

        JSON value:
                Invalid value is invalid_name
`

I expect to be able to determine Expected type because in above case it is undefined

Metadata

Metadata

Labels

enhancementNew feature or requestinvalidThis doesn't seem right

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions