Skip to content

error TS1206: on anonymous class #8176

@devpaul

Description

@devpaul

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."

const decorator: MethodDecorator = function (target: Object, propertyKey: string,
    descriptor: TypedPropertyDescriptor<any>): TypedPropertyDescriptor<any> {
    return descriptor;
};
const C = class { 
    @decorator method() {} 
};

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions