ts-jest: Broken Date type reflection mechanizm

There is an issue in a transpilation mechanizm that ts-node also use: https://github.com/TypeStrong/ts-node/issues/511

import "reflect-metadata";

const CollectMetadata: PropertyDecorator = (target, propertyKey) => {
    const ReflectType = Reflect.getMetadata("design:type", target, propertyKey);
    console.log(ReflectType);
    console.log(ReflectType === Date);
}

class Test {
    @CollectMetadata
    property: Date;
}

The workaround is to use --type-check flag with ts-node. Is there an equivalent of that option in ts-jest? Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 28 (3 by maintainers)

Most upvoted comments

Same issue here with TypeORM.

For the record, I’ve confirmed this is working with TS 2.9.1 as well.

Just confirmed the issue is fixed with typescript@next. I’ll confirm it is fixed in typescript@2.9.1 when it is released later this week.

Thanks!

(Interestingly enough, the typescript team has told me on twitter that the reflection might be a bug in their implementation of transpileModule, hold your horses for this one)

@GeeWee It looks like @akheron put together a repo with an isolated test case here: https://github.com/akheron/ts-jest-test

I ask that we reopen this issue. Both this issue and #445, which I created, were closed but we have 4 people having the same issue in the span of a few days so this issue is probably not going away.

As mentioned in #445, a similar issue is solved in ts-node by using the --type-check flag. I did a brief dive into their code, and while I’m not an expert in ts compilation, it seems like they’re just setting additional compiler settings.

I also have this problem. I made a repo that demonstrates the issue: https://github.com/akheron/ts-jest-test