title: How can one determine if an object is a ViewRef?
body: <p>I have a class that I'm using in multiple places in my application.</p>
  
  <pre><code>import { TemplateRef } from '@angular/core';
  
  export class ObjectPropertyDisplayStrategy&lt;T&gt; {
    content: TemplateRef&lt;any&gt; | ((record: T) =&gt; string) | string;
    displayStrategyType: DisplayStrategyType;
  
    constructor(content: TemplateRef&lt;any&gt; | ((record: T) =&gt; string) | string) {
      this.content = content;
      setDisplayStrategyType(this, content);
    }
  }
  </code></pre>
  
  <p>As can be seen by the Typescript annotations, the constructor expects a parameter to be passed to it that is of type <code>TemplateRef</code> or <code>Function</code> or <code>String</code>. It then passes this parameter to a function <code>setDisplayStrategyType</code></p>
  
  <pre><code>function setDisplayStrategyType(
    displayStrategy: { displayStrategyType: DisplayStrategyType },
    content: TemplateRef&lt;any&gt; | ((record: any) =&gt; string) | string
  ) {
    if (Object.getPrototypeOf(content).constructor.name === 'TemplateRef_') {
      displayStrategy.displayStrategyType = DisplayStrategyType.Template;
      return;
    }
  
    switch (typeof content) {
      case typeof Function:
      displayStrategy.displayStrategyType = DisplayStrategyType.FunctionTransform;
        break;
      case typeof String:
      default:
      displayStrategy.displayStrategyType = DisplayStrategyType.String;
        break;
    }
  }
  </code></pre>
  
  <p>This function tries to determine which of the three types was passed as the parameter and then sets an enum value which allows some display logic to occur in an Angular component.</p>
  
  <p>For the <code>TemplateRef</code> type specifically, it is being determined through the following logic: <code>if (Object.getPrototypeOf(content).constructor.name === 'TemplateRef_')</code>. This works when I build the project using <code>ng build</code>. When I run <code>ng build --prod</code> though, it stops working and seems to be due to the fact that when everything gets uglified, the <code>TemplateRef_</code> object gets changed to something like <code>e</code>. This issue is mentioned in the first comment on the answer <a href="https://stackoverflow.com/questions/10314338/get-name-of-object-or-class#answer-10314492">here</a>.</p>
  
  <p>I've tried utilizing the <code>TemplateRef</code> symbol to deal with this issue as follows:</p>
  
  <pre><code>const a = typeof TemplateRef;
  const b = new TemplateRef();
  const c = Object.getPrototypeOf(TemplateRef);
  </code></pre>
  
  <p>As well as the <code>ViewChild</code> decorator as that seems to be one way in Angular to create a <code>TemplateRef</code> instance.</p>
  
  <pre><code>const a = typeof ViewChild;
  const b = new ViewChild();
  const c = Object.getPrototypeOf(ViewChild);
  </code></pre>
  
  <p>None of these strategies seem to work though. Is there a reliable way to construct a new <code>TemplateRef</code> object that I could compare 'types' with my passed property or another way to make this determination so that my library can continue to work with a prod build?</p>