Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: No valid 'type' option was specified for 'xxx' #85

Open
theapache64 opened this issue Jun 28, 2018 · 1 comment
Open

Error: No valid 'type' option was specified for 'xxx' #85

theapache64 opened this issue Jun 28, 2018 · 1 comment

Comments

@theapache64
Copy link

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
Copy link
Collaborator

Neos3452 commented Dec 9, 2018

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;
  
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants