jeudi 16 février 2017

Correct way to reference reflect-metadata or equivalent in angular app

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()





Aucun commentaire:

Enregistrer un commentaire