<p dir="auto">I am trying to use a decorator with an anonymous class (class expression) on TypeScript 1.8.9 and am receiving the error: "error TS1206: Decorators are not valid here."</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const decorator: MethodDecorator = function (target: Object, propertyKey: string,
    descriptor: TypedPropertyDescriptor&lt;any&gt;): TypedPropertyDescriptor&lt;any&gt; {
    return descriptor;
};
const C = class { 
    @decorator method() {} 
};"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-en">decorator</span>: <span class="pl-smi">MethodDecorator</span> <span class="pl-c1">=</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">target</span>: <span class="pl-smi">Object</span><span class="pl-kos">,</span> <span class="pl-s1">propertyKey</span>: <span class="pl-smi">string</span><span class="pl-kos">,</span>
    <span class="pl-s1">descriptor</span>: <span class="pl-smi">TypedPropertyDescriptor</span><span class="pl-kos">&lt;</span><span class="pl-smi">any</span><span class="pl-kos">&gt;</span><span class="pl-kos">)</span>: <span class="pl-smi">TypedPropertyDescriptor</span><span class="pl-kos">&lt;</span><span class="pl-smi">any</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">return</span> <span class="pl-s1">descriptor</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-smi">C</span> <span class="pl-c1">=</span> <span class="pl-k">class</span> <span class="pl-kos">{</span> 
    @<span class="pl-s1">decorator</span> <span class="pl-en">method</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span><span class="pl-kos">}</span> 
<span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">I didn't see anything addressing decorating anonymous classes in the roadmap, so I am filing this issue to either provide clarification to other people in my situation or to mark a bug.</p>
<p dir="auto">Not sure if this is by design or not, but the following gives a compile error of "Decorators are not valid here" with TypeScript 1.8:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="let testClass = new class {
    testMethod(@myDecorator date: Date): any {
        return date;
    }
}();"><pre class="notranslate"><span class="pl-k">let</span> <span class="pl-s1">testClass</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-k">class</span> <span class="pl-kos">{</span>
    <span class="pl-en">testMethod</span><span class="pl-kos">(</span>@<span class="pl-s1">myDecorator</span> <span class="pl-s1">date</span>: <span class="pl-smi">Date</span><span class="pl-kos">)</span>: <span class="pl-smi">any</span> <span class="pl-kos">{</span>
        <span class="pl-k">return</span> <span class="pl-s1">date</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>