In this plunker I'm attempting to decorate a property on MyModel with a custom annotation. Un-commenting the property with custom decorator or un-commenting import 'reflect-metadata';
and the property with inline decorator generates:
Error: Cannot resolve all parameters for 'Parser'(?). Make sure that all the parameters are decorated with Inject or have valid type annotations and that 'Parser' is decorated with Injectable. at NoAnnotationError.ZoneAwareError
I can un-comment just the inline decorator but in an editor without the import 'reflect-metadata';
you don't get code autocomplete and tsc error about metadata() not being a property of Reflect.
What is the correct way to use the reflect API in angular?
Edit:
With a new @angular/cli genrated app you have import 'core-js/es7/reflect';
in pollyfills.ts
but you still get Property 'metadata' does not exist on type 'typeof Reflect'.
if you try any combination of Reflect.metadata()
Edit2:
I seemingly have this working in angular cli by replacing import 'core-js/es7/reflect';
with import 'reflect-metadata';
in pollyfills.ts
but I don't know if they are one for one replacements or if there is ramifications. The answer here isn't clear to me. Angular2 using either npm reflect-metadata or core-js/es7/reflect