Incorrect type for `ClassDecorator`
See original GitHub issueThe 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:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top 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 >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
Would that still work with abstract classes?
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.