Runtime fixes for stage 3 decorators

This commit is contained in:
Matt Bierner
2025-08-06 14:32:43 -07:00
parent d8c9852fe9
commit 2baf1b4cde
4 changed files with 15 additions and 51 deletions

View File

@@ -24,23 +24,11 @@ export class DisposableStore {
}
function decorate(decorator: (fn: Function, key: string) => Function): Function {
return (_target: any, key: string, descriptor: any) => {
let fnKey: string | null = null;
let fn: Function | null = null;
if (typeof descriptor.value === 'function') {
fnKey = 'value';
fn = descriptor.value;
} else if (typeof descriptor.get === 'function') {
fnKey = 'get';
fn = descriptor.get;
return function (original: any, context: ClassMethodDecoratorContext) {
if (context.kind === 'method' || context.kind === 'getter' || context.kind === 'setter') {
return decorator(original, context.name.toString());
}
if (!fn || !fnKey) {
throw new Error('not supported');
}
descriptor[fnKey] = decorator(fn, key);
throw new Error('not supported');
};
}