Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error TS1206: Decorators are not valid here. in anonymous class #51507

Closed
Redvik80 opened this issue Nov 13, 2022 · 2 comments
Closed

error TS1206: Decorators are not valid here. in anonymous class #51507

Redvik80 opened this issue Nov 13, 2022 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@Redvik80
Copy link

function testDecorator(target: any, key: string) {
    console.log(target, key);
}

export const testMixin = (superClass: any = Object) => class extends superClass {
    @testDecorator testField: string;
}

This produces the following compiler error:
error TS1206: Decorators are not valid here.

export const testMixin = (superClass: any = Object) => {
    class Mixin extends superClass {
        @testDecorator testField: string;
    }
    return Mixin;
}

In the second case, there are no problems.

@MartinJohns
Copy link
Contributor

Duplicate of #7342.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Nov 17, 2022
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants