mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Experimental decorator added
This commit is contained in:
1
declarations.d.ts
vendored
1
declarations.d.ts
vendored
@@ -103,6 +103,7 @@ declare var require: NativeScriptRequire;
|
|||||||
|
|
||||||
// Global functions
|
// Global functions
|
||||||
declare function Deprecated(target: Object, key?: string | symbol, value?: any): void;
|
declare function Deprecated(target: Object, key?: string | symbol, value?: any): void;
|
||||||
|
declare function Experimental(target: Object, key?: string | symbol, value?: any): void;
|
||||||
|
|
||||||
declare function Log(data: any): void;
|
declare function Log(data: any): void;
|
||||||
declare function log(data: any): void;
|
declare function log(data: any): void;
|
||||||
|
|||||||
@@ -137,3 +137,22 @@ export function Deprecated(target: Object, key?: string | symbol, descriptor?: a
|
|||||||
}
|
}
|
||||||
|
|
||||||
global.Deprecated = Deprecated;
|
global.Deprecated = Deprecated;
|
||||||
|
|
||||||
|
export function Experimental(target: Object, key?: string | symbol, descriptor?: any) {
|
||||||
|
if (descriptor) {
|
||||||
|
var originalMethod = descriptor.value;
|
||||||
|
|
||||||
|
descriptor.value = function (...args: any[]) {
|
||||||
|
console.log(`${key} is experimental`);
|
||||||
|
|
||||||
|
return originalMethod.apply(this, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
return descriptor;
|
||||||
|
} else {
|
||||||
|
console.log(`${(target && (<any>target).name || target)} is experimental`);
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
global.Experimental = Experimental;
|
||||||
Reference in New Issue
Block a user