-1

I have a framework that uses metadata with decorator in TypeScript so I know it is working.

However, today I just found a bizarre basic case that I can't figure out why.

It is reproducible in TS@2.1.5, @2.1.6, and @2.2.0-dev.20170214

The issue can be demo in https://github.com/unional/some-issues/tree/ts-meta-import

Summary of the situation

// Foo.ts
import 'reflect-metadata'

@Reflect.metadata('somekey', 123)
export class Foo { }

Reflect.getMetadata('somekey', Foo) // returns 123

The above code works fine, however if I try to access Foo in a different file and do the same thing, it doesn't work:

import 'reflect-metadata'
import { Foo } from './Foo'

Reflect.getMetadata('somekey', Foo) // returns undefined

It really shouldn't be the case....

UPDATE: in my framework, I'm using aurelia-metadata and it seems to work in this case. But the question remains, why this "simple" scenario doesn't work with reflect-metadata?

unional
  • 14,651
  • 5
  • 32
  • 56

1 Answers1

-1

The answer is that it does work. For some reason, when I try it today, it started working.

The unicorn just pass by.

Thanks @blakeembrey for taking a look into this.

unional
  • 14,651
  • 5
  • 32
  • 56