We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Consider the following code sample:
const Decorator = () => { return (target: object, key: string | symbol, index?: number) => { } } const Foo = class { constructor(@Decorator() foo: string) { } } const Foo1 = class Foo1 { constructor(@Decorator() foo: string) { } } class Bar { constructor(@Decorator() foo: string) { } }
TypeScript fails at compiling this code and throws the following compilation error for Foo and Foo1 classes:
error TS1206: Decorators are not valid here.
Class Bar compiles successfully.
Since
class Foo { }
and
const Foo = class { }
are equivalent syntaxes in ES6, using parameter decorators should be allowed for these two syntaxes.
The text was updated successfully, but these errors were encountered:
To give a bit of context, allowing parameter decorators for anonymous classes would permit writing things like this in nestjs:
@Module({ providers: [{ provide: CatsService, useClass: class { constructor(@Inject(MyService) private readonly myService: MyServiceInterface) { } } }, MyService], }) export class AppModule { }
Instead of having to declare the class first and then assign it to useClass.
useClass
Sorry, something went wrong.
Duplicate #7342
Sorry about that. I close.
No branches or pull requests
Consider the following code sample:
🙁 Actual behavior
TypeScript fails at compiling this code and throws the following compilation error for Foo and Foo1 classes:
Class Bar compiles successfully.
🙂 Expected behavior
Since
and
are equivalent syntaxes in ES6, using parameter decorators should be allowed for these two syntaxes.
The text was updated successfully, but these errors were encountered: