-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Angular's metadata decorators (@Componentetc) aren't really runtime decorators, they're used more like "annotations". Angular tooling has the ability to "downlevel" these decorannoations into static class properties, which are then read by Angular's reflector.
This is accomplished w/ a JSDoc annotation - see https://github.com/angular/angular/blob/a80ac0a8d3238f483a05252c437d4b321c42f5c7/packages/core/src/metadata/directives.ts#L67-L68
When run through ngc with the annotateForClosureCompiler option, usages of decorators tagged with this JSDoc are rewritten:
/**
* @Annotation
**/
export function Effect(args?){ return function(...args?){} }used like
class Foo {
@Effect() someProp:whatever
}downlevels to
class Foo {}
Foo.propDecorators = {
foo: [{type: Effect, args: [] }]
}For full closure compatibility, we need to implement the same functionality - at runtime, we just need to check those static properties before checking via Reflect, as seen in : https://github.com/angular/angular/blob/master/packages/core/src/reflection/reflection_capabilities.ts#L73-L85
internal bug : b/63801869