<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="const bar = (target: any, name: any, value: any) =&gt; {
  const parentName = target.constructor.name
  console.log(parentName)
}
class a {
  @bar
  public foo() {
  }
}"><pre class="notranslate"><code class="notranslate">const bar = (target: any, name: any, value: any) =&gt; {
  const parentName = target.constructor.name
  console.log(parentName)
}
class a {
  @bar
  public foo() {
  }
}
</code></pre></div>
<p dir="auto">It works. <em>But</em></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="const bar = (target: any, name: any, value: any) =&gt; {
  const parentName = target.constructor.name
  console.log(parentName)
 // it would be an empty string here!!!!!!!!
}
const log = (target: any) =&gt; {}

@log
class a {
  @bar
  public foo() {
  }
}"><pre class="notranslate"><code class="notranslate">const bar = (target: any, name: any, value: any) =&gt; {
  const parentName = target.constructor.name
  console.log(parentName)
 // it would be an empty string here!!!!!!!!
}
const log = (target: any) =&gt; {}

@log
class a {
  @bar
  public foo() {
  }
}
</code></pre></div>
<p dir="auto">these code is ok when compile target was <code class="notranslate">ES5</code>, but missing class name when target was <code class="notranslate">ES6</code></p>
<p dir="auto">I have decorator:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export function Document() {
   return function(objectConstructor: Function) {
        console.log(objectConstructor.name); // when targeting es5 it gives me what I want - the name of my class. When targeting es6 it does not give anything
    }
}"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">function</span> <span class="pl-smi">Document</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
   <span class="pl-k">return</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-s1">objectConstructor</span>: <span class="pl-smi">Function</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">objectConstructor</span><span class="pl-kos">.</span><span class="pl-c1">name</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// when targeting es5 it gives me what I want - the name of my class. When targeting es6 it does not give anything</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Here is decorator usage:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="@Document()
export class User {
}"><pre class="notranslate">@<span class="pl-smi">Document</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
<span class="pl-k">export</span> <span class="pl-k">class</span> <span class="pl-smi">User</span> <span class="pl-kos">{</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Im using "User" class name to create a document called "User", I need information how class is called. I always used es5, but now when I switched to es6 compile target I dont have information about class name anymore. Is it a bug, or it by design? If second then what is the way to get the class name?</p>