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.

Incorrect type for `ClassDecorator`

See original GitHub issue

The current (3.2.2) type for class decorator function seems to be incomplete:

declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;

It says that target should extend a Function, but it should be something like NewableFunction I guess, since its a class constructor and it can be passed to new.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
ajafffcommented, Feb 8, 2019

Would that still work with abstract classes?

0reactions
canonic-epicurecommented, Dec 10, 2020

Also note, that application of class decorators does not generate error, even that the intention is to decorate only subclasses of Serializable.

I believe ClassDecorator should accept an optional argument with the base class that can be decorated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incorrect type for `ClassDecorator` · Issue #29828 - GitHub
The current (3.2.2) type for class decorator function seems to be incomplete: declare type ClassDecorator = <TFunction extends Function>(target: ...
Read more >
Wrong inferred type when a class decorator replaces it with an ...
Wrong inferred type when a class decorator replaces it with an instance. 2. Relates to 3 Is duplicated by 1. Relates to 3...
Read more >
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 >
TypeScript: get wrong object when use Property Decorator
The TypeScript documentation says that instance property decorators receive the class prototype as the first argument.
Read more >
@prop | typegoose
class Cat2 { @prop({ type: () => String }) // explicitly define the Type ... Should act like the @index class decorator, but...
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