Decorators not allowed classes expressions
See original GitHub issueNot 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:
let testClass = new class {
testMethod(@myDecorator date: Date): any {
return date;
}
}();
Issue Analytics
- State:
- Created 8 years ago
- Reactions:85
- Comments:28 (7 by maintainers)
Top Results From Across the Web
Documentation - Decorators - TypeScript
A Decorator is a special kind of declaration that can be attached to a class declaration, method, accessor, property, or parameter. Decorators use...
Read more >Decorators is not valid when returning a class on a function?
Decorators are not allowed in class expressions. You can easily work around this by defining the class, then returning it:
Read more >ICS 33 Fall 2022, Notes and Examples: Decorators
We decorate a function by adding a decorator expression above it, in which we specify ... Why not assign the name function into...
Read more >Google TypeScript Style Guide
UpperCamelCase, class / interface / type / enum / decorator / type parameters ... not needed constructor(public baz: Baz) {} // public modifier...
Read more >How To Use Decorators in TypeScript - DigitalOcean
Unable to resolve signature of class decorator when called as an expression. Type '(target: Function) => void' is not assignable to type ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
Top GitHub Comments
This also applies when using the new 2.2 mixin design.
I.e.
Is this something that should work?
they were never enabled for class expressions. so the behavior has not changed. but they should.