microsoft / microsoft/reflect-metadata

Empty value on production build

Open
#67 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.4k
Forks
190
Avg merge
13h 52m
Merged PRs (30d)
1

Description

Hello. I'm trying to get selector value and use it in my component class, but on production annotations[0].selector is empty.

import { Directive, ElementRef, AfterContentInit } from '@angular/core';

@Directive({
  selector: '[appLinkedCheckbox]'
})
export class LinkedCheckboxDirective implements AfterContentInit {
  private el: HTMLElement;

  constructor(el: ElementRef) {
    this.el = el.nativeElement;
  }

  public ngAfterContentInit() {
    let annotations = Reflect.getMetadata('annotations', this.constructor);
    let selector    = annotations[0].selector;  // This value is empty on production build
  }
}

@angular/cli: 1.0.0-rc.0
node: 7.7.4
os: darwin x64
@angular/common: 2.4.10
@angular/compiler: 2.4.10
@angular/core: 2.4.10
@angular/forms: 2.4.10
@angular/http: 2.4.10
@angular/platform-browser: 2.4.10
@angular/platform-browser-dynamic: 2.4.10
@angular/platform-server: 2.4.10
@angular/router: 3.4.10
@angular/compiler-cli: 2.4.10
@angular/cli: 1.0.0-rc.0

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported difference between development and production builds around Reflect.getMetadata('annotations', this.constructor). Compare the selector value from the shown Angular directive in both builds and determine whether the metadata remains available. Done means the production build behavior is explained and the selector is consistently retrievable or the limitation is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.