question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Method decorators in class expressions are silently ignored.

See original GitHub issue

TypeScript 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:

https://www.typescriptlang.org/play/index.html#src=const decorator %3D () %3D> null%3B class Statement { %40decorator() method() { } } (class Expression { %40decorator() method() { } })

Related Issues:

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
brandonbloomcommented, Dec 10, 2018

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?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/TypeScript/issues/28903#issuecomment-445706623, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHRfK6C9Vz3orVMGYDGN_yrTOaevoDzks5u3gWmgaJpZM4ZI9Yg .

0reactions
DanielRosenwassercommented, Dec 10, 2018

So what’s the deal, would we consider this a bug or a design limitation?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found