Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement @Annotation style decorator down-leveling for Closure Compatibility #93

Closed
robwormald opened this issue Jul 18, 2017 · 0 comments · Fixed by #98
Closed

Implement @Annotation style decorator down-leveling for Closure Compatibility #93

robwormald opened this issue Jul 18, 2017 · 0 comments · Fixed by #98

Comments

@robwormald
Copy link
Contributor

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

@robwormald robwormald self-assigned this Jul 18, 2017
MikeRyanDev pushed a commit that referenced this issue Jul 18, 2017
Applications using Google Closure Compiler with Angular's ngc can opt into downleveling specifically marked decorators into static properties. This change enables that usage.

Closes #93
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant