Skip to content

Commit 6a12529

Browse files
authored
Merge branch 'main' into tyriar/258480
2 parents 50475cf + b4d9140 commit 6a12529

File tree

38 files changed

+470
-270
lines changed

38 files changed

+470
-270
lines changed

extensions/git-base/src/decorators.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,10 @@ function _throttle<T>(fn: Function, key: string): Function {
4848
}
4949

5050
function decorate(decorator: (fn: Function, key: string) => Function): Function {
51-
return (_target: any, key: string, descriptor: any) => {
52-
let fnKey: string | null = null;
53-
let fn: Function | null = null;
54-
55-
if (typeof descriptor.value === 'function') {
56-
fnKey = 'value';
57-
fn = descriptor.value;
58-
} else if (typeof descriptor.get === 'function') {
59-
fnKey = 'get';
60-
fn = descriptor.get;
61-
}
62-
63-
if (!fn || !fnKey) {
51+
return function (original: any, context: ClassMethodDecoratorContext) {
52+
if (context.kind !== 'method') {
6453
throw new Error('not supported');
6554
}
66-
67-
descriptor[fnKey] = decorator(fn, key);
55+
return decorator(original, context.name.toString());
6856
};
6957
}

extensions/git-base/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"extends": "../tsconfig.base.json",
33
"compilerOptions": {
44
"outDir": "./out",
5-
"experimentalDecorators": true,
65
"typeRoots": [
76
"./node_modules/@types"
87
]

extensions/git/src/api/extension.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import { GitExtension, Repository, API } from './git';
88
import { ApiRepository, ApiImpl } from './api1';
99
import { Event, EventEmitter } from 'vscode';
1010

11-
export function deprecated(_target: any, key: string, descriptor: any): void {
12-
if (typeof descriptor.value !== 'function') {
11+
function deprecated(original: any, context: ClassMemberDecoratorContext) {
12+
if (context.kind !== 'method') {
1313
throw new Error('not supported');
1414
}
1515

16-
const fn = descriptor.value;
17-
descriptor.value = function () {
16+
const key = context.name.toString();
17+
return function (this: any, ...args: any[]): any {
1818
console.warn(`Git extension API method '${key}' is deprecated.`);
19-
return fn.apply(this, arguments);
19+
return original.apply(this, args);
2020
};
2121
}
2222

extensions/git/src/commands.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,12 @@ interface ScmCommand {
363363
const Commands: ScmCommand[] = [];
364364

365365
function command(commandId: string, options: ScmCommandOptions = {}): Function {
366-
return (_target: any, key: string, descriptor: any) => {
367-
if (!(typeof descriptor.value === 'function')) {
366+
return (value: any, context: ClassMethodDecoratorContext) => {
367+
if (context.kind !== 'method') {
368368
throw new Error('not supported');
369369
}
370-
371-
Commands.push({ commandId, key, method: descriptor.value, options });
370+
const key = context.name.toString();
371+
Commands.push({ commandId, key, method: value, options });
372372
};
373373
}
374374

extensions/git/src/decorators.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,11 @@
66
import { done } from './util';
77

88
function decorate(decorator: (fn: Function, key: string) => Function): Function {
9-
return (_target: any, key: string, descriptor: any) => {
10-
let fnKey: string | null = null;
11-
let fn: Function | null = null;
12-
13-
if (typeof descriptor.value === 'function') {
14-
fnKey = 'value';
15-
fn = descriptor.value;
16-
} else if (typeof descriptor.get === 'function') {
17-
fnKey = 'get';
18-
fn = descriptor.get;
9+
return function (original: any, context: ClassMethodDecoratorContext) {
10+
if (context.kind === 'method' || context.kind === 'getter' || context.kind === 'setter') {
11+
return decorator(original, context.name.toString());
1912
}
20-
21-
if (!fn || !fnKey) {
22-
throw new Error('not supported');
23-
}
24-
25-
descriptor[fnKey] = decorator(fn, key);
13+
throw new Error('not supported');
2614
};
2715
}
2816

extensions/git/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"extends": "../tsconfig.base.json",
33
"compilerOptions": {
44
"outDir": "./out",
5-
"experimentalDecorators": true,
65
"typeRoots": [
76
"./node_modules/@types"
87
]

extensions/github-authentication/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"extends": "../tsconfig.base.json",
33
"compilerOptions": {
44
"outDir": "./out",
5-
"experimentalDecorators": true,
65
"typeRoots": [
76
"./node_modules/@types"
87
],

extensions/github/src/util.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,11 @@ export class DisposableStore {
2424
}
2525

2626
function decorate(decorator: (fn: Function, key: string) => Function): Function {
27-
return (_target: any, key: string, descriptor: any) => {
28-
let fnKey: string | null = null;
29-
let fn: Function | null = null;
30-
31-
if (typeof descriptor.value === 'function') {
32-
fnKey = 'value';
33-
fn = descriptor.value;
34-
} else if (typeof descriptor.get === 'function') {
35-
fnKey = 'get';
36-
fn = descriptor.get;
27+
return function (original: any, context: ClassMethodDecoratorContext) {
28+
if (context.kind === 'method' || context.kind === 'getter' || context.kind === 'setter') {
29+
return decorator(original, context.name.toString());
3730
}
38-
39-
if (!fn || !fnKey) {
40-
throw new Error('not supported');
41-
}
42-
43-
descriptor[fnKey] = decorator(fn, key);
31+
throw new Error('not supported');
4432
};
4533
}
4634

extensions/github/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"moduleResolution": "NodeNext",
66
"outDir": "./out",
77
"skipLibCheck": true,
8-
"experimentalDecorators": true,
98
"allowSyntheticDefaultImports": false,
109
"typeRoots": [
1110
"./node_modules/@types"

extensions/microsoft-authentication/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"extends": "../tsconfig.base.json",
33
"compilerOptions": {
44
"baseUrl": ".",
5-
"experimentalDecorators": true,
65
"module": "commonjs",
76
"moduleResolution": "node",
87
"noFallthroughCasesInSwitch": true,

0 commit comments

Comments
 (0)