I am trying to use reflection and Typescript decorators. My library uses the reflect-metadata polyfill. The babel-plugin-transform-runtime plugin is clobbering the references to Reflect in my test files, resulting in two reflection registries and thus breaking reflection between my library and the test file. I am unable to test decorators from my library. I made a simple repo to illustrate the issue: https://github.com/dwieeb/ava-decorators
I had to use ava from master in order to debug tests in subprocesses and ultimately see that babel is wiping out the global Reflect and also substituting my polyfill for some core-js thing.
node 6
npm 3
relevant, unresolved: https://github.com/avajs/ava/issues/947
relevant, unresolved: #947
That would be the solution, yes.
Meanwhile you could try something like this: https://github.com/novemberborn/buoyant/blob/4015fd703a4f26a4965f12a60c221fbb372ed3b3/test/lib/Scheduler.js#L11:L12
Let me know how that works for you and I'll see if we can this to the Common Pitfalls documentation.
Yes, that works. My tests are working as expected now.
@dwieeb hey, just came across the same issue. What did you do for it to work? Adding const { Reflect } = global seems not to work.
Thanks in advance :)
@lholznagel I did this, but I think const { Reflect } = global should work, too(?):
const g = <any>global;
const Reflect = g.Reflect;
Ah thanks!
With my code I get this error:
'Global' has no property 'Reflect' and no string index signature
Really didn麓t think about adding <any>. When adding <any> it works :+1:
End result looks like this: const { Reflect } = <any> global;
My test now works, thanks for your help :+1:
As of #1197 master no longer applies the runtime transform.
Most helpful comment
As of #1197
masterno longer applies the runtime transform.