Error: No valid 'type' option was specified for 'xxx'
Opened this issue · 1 comments
theapache64 commented
When I try to run this
import { JsonMember, JsonObject } from 'typedjson-npm';
@JsonObject
class User {
@JsonMember
first_name: string;
@JsonMember
last_name: string;
}
I am getting
Error: No valid 'type' option was specified for 'User.first_name'.
Any idea why it occurred ?
Neos3452 commented
Hey, do you use reflect-metadata package? It is required for the types to be automatically guessed. If you don't want the extra package, you can manually annotate the member. With the new version available from npm (1.2.3), this is as easy as:
import { jsonMember, jsonObject } from 'typedjson';
@jsonObject
class User {
@jsonMember(String)
first_name: string;
@jsonMember(String)
last_name: string;
}