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

Date type is Object #84

Closed
DevidCIC opened this issue Nov 21, 2017 · 2 comments
Closed

Date type is Object #84

DevidCIC opened this issue Nov 21, 2017 · 2 comments
Labels

Comments

@DevidCIC
Copy link

Using reflect-metadata with TypeScript. On a parameter of Type Date the type a get through the reflect-metadata library is Object.

Is there no possibility to get Date back ?

@MichalLytek
Copy link

MichalLytek commented Jan 13, 2018

@DevidCIC
I have the same problem, I can't get the Date type inside property decorator:

Reflect.getMetadata("design:type", target, propertyKey);

I get only the Object function. It works ok with number, strings, custom classes, etc. Also in sources the emitted looks ok and there's Date, not Object.

However it's weird that when I edit the JS file and add this line in the end, I got proper Date function:

let Rate = class Rate {
};
__decorate([
    Field_1.Field(type => scalars_1.Int),
    __metadata("design:type", Number)
], Rate.prototype, "value", void 0);
__decorate([
    Field_1.Field(),
    __metadata("design:type", Date)
], Rate.prototype, "date", void 0);
__decorate([
    Field_1.Field(),
    __metadata("design:type", User)
], Rate.prototype, "user", void 0);
Rate = __decorate([
    GraphQLType_1.GraphQLType()
], Rate);
exports.Rate = Rate;

console.log("date type", Reflect.getMetadata("design:type", Rate.prototype, "date"));

Looks like ts-node is the problem, when I compile the sources and run JS in node, it works great! 😉

@Alexandredc
Copy link

Alexandredc commented Jan 30, 2018

Same problem here, I think is a ts-node issue

Check this issue: TypeStrong/ts-node#511

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

No branches or pull requests

4 participants