Experimental decorator added

This commit is contained in:
Vladimir Enchev
2016-02-15 15:48:54 +02:00
parent c0682fce80
commit ef7394f80f
2 changed files with 20 additions and 0 deletions

1
declarations.d.ts vendored
View File

@@ -103,6 +103,7 @@ declare var require: NativeScriptRequire;
// Global functions
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;

View File

@@ -137,3 +137,22 @@ export function Deprecated(target: Object, key?: string | symbol, descriptor?: a
}
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;