question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ts-node breaks Date reflection mechanism

See original GitHub issue
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;
}

ts-node output:

PS E:\#Programowanie\#GitHub\type-graphql> npx ts-node src/date.ts
E:\#Programowanie\#GitHub\type-graphql\node_modules\ts-node\dist\bin.js
[Function: Object]
false

tsc and node output:

PS E:\#Programowanie\#GitHub\type-graphql> npx tsc; node build/date.js
E:\#Programowanie\#GitHub\type-graphql\node_modules\typescript\bin\tsc
[Function: Date]
true

I have no idea what’s going on, how can we check the emitted js files? I’m using ts-node 4.1.0 😉

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
MichalLytekcommented, Feb 20, 2018

I would imagine every type information reflection would not work with type information, but perhaps it’s only type information from external files? I have not verified this.

I’ve tested it and every single reflection works (classes from external files, String, Number, Boolean, etc.), only the Date is reflected as Object in this mode. That’s why it’s weird, should we bump the question to the TS team?

2reactions
EvanDarwincommented, Jan 25, 2018

👍 I’ve also encountered this issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Methods for TypeScript runtime type checking - LogRocket Blog
Explore five methods of performing TypeScript type checks at runtime in this post and learn each of their advantages and disadvantages.
Read more >
ts-node-dev doesn't apply changes in auto reload
says that the server has restarted when a typescript file is changed, the change is not applyed.
Read more >
Safari Technology Preview Release Notes - Apple Developer
Fixed non-breaking space getting inserted instead of a normal space character between ... Changed to grayscale nodes in the DOM tree that are...
Read more >
Reflection in Typescript - Sergey Radzishevskii - Medium
Languages like C#, Java, PHP have a reflection mechanism. Reflection is a feature in the Java programming language.
Read more >
Release Notes — Airflow Documentation
Logical date of a DAG run triggered from the web UI now have its sub-second component set to zero¶. Due to a change...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found