Let's assume you have class decorator defined as follows:
const foo: ClassDecorator = (target) => {
return class FooBar extends (target as any as Constructor<any>) {
someProperty = true;
}
};
@foo
class Bar {}
(new Bar).someProperty; // TS2339: Property 'someProperty' does not exist on type 'Bar'.
Well, ClassDecorator
is defined by TypeScript as:
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
ClassDecorator
for mixins should probably look like:
declare type Mixin<TFunction extends Constructor<InstanceType>, InstanceType=any, MixedInstance={}, MixedStatic={}> = Constructor<InstanceType & MixedInstance> & MixedStatic
Having MethodDecorator
and PropertyDecorator
with explicit typing would be nice too, but writing them seems to be really complicated and likely to run in edge cases.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too