Method decorators in class expressions are silently ignored.
See original GitHub issueTypeScript Version: 3.2
Search Terms:
- decorators
- class expressions
Code
const decorator = () => null;
// This calls __decorate with decorator.
class Statement {
@decorator()
method() {
}
}
// This doesn't! It also doesn't produce a compiler error of any kind.
(class Expression {
@decorator()
method() {
}
})
Expected behavior:
__decorate should be called, or a compiler error should be produced.
Actual behavior:
The decorator is silently ignored, omitting it from the decoration compiled output.
Playground Link:
Related Issues:
-
Using decorators on arguments in class expressions produces a compiler error: https://github.com/Microsoft/TypeScript/issues/7342
-
This one is about decorators on class expressions, not methods within a class expression: https://github.com/Microsoft/TypeScript/issues/15975 - but produces some kind of error at least.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
How to skip or ignore python decorators - Stack Overflow
I'd like to call that function without the HTML-wrapping of the decorator. Is that even possible? Example: class a: @HTMLwrapper def returnStuff ...
Read more >PythonDecorators - Python Wiki
Decorators dynamically alter the functionality of a function, method ... + Will not be silently ignored; + Compile-time; + One decorator per ...
Read more >4.6.7. pde.tools.misc module — py-pde 0.22.3 documentation
decorator that makes vectorized methods work with scalars ... (bool) – Flag indicating whether serialization errors are raised or silently ignored. class ...
Read more >https://matplotlib.org/stable/_sources/api/prev_ap...
Axis` class, and is used regardless of the locator class. ... TextPath` constructor used to silently drop ignored arguments; this behavior is deprecated....
Read more >Python's assert: Debug and Test Your Code Like a Pro
With a truthy expression, the assertion succeeds, and nothing happens. ... In Python, assert is a statement instead of a function.
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
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For what it’s worth as input to your issue classification process: The project in which this issue was discovered has some decorators that are performing access control for an HTTP API. Switching from Babel to TypeScript with allowJS meant that a bunch of security was silently turned off!
On Sun, Dec 9, 2018 at 10:56 PM Daniel Rosenwasser notifications@github.com wrote:
So what’s the deal, would we consider this a bug or a design limitation?