diff --git a/declarations.d.ts b/declarations.d.ts index 044782789..c3427ab6a 100644 --- a/declarations.d.ts +++ b/declarations.d.ts @@ -16,7 +16,23 @@ declare var console: Console; declare var global; declare var require; +interface TypedPropertyDescriptor { + enumerable?: boolean; + configurable?: boolean; + writable?: boolean; + value?: T; + get?: () => T; + set?: (value: T) => void; +} + +declare type ClassDecorator = (target: TFunction) => TFunction | void; +declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void; +declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; +declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void; + // Global functions +declare function Deprecated(target: Object, key?: string | symbol, value?: any): void; + declare function Log(data: any): void; declare function log(data: any): void; declare function float(num: number): any; diff --git a/globals/globals.ts b/globals/globals.ts index 1da80f3a0..b20dbe4f4 100644 --- a/globals/globals.ts +++ b/globals/globals.ts @@ -15,4 +15,24 @@ if (types.isUndefined(global.NSObject)) { } global.XMLHttpRequest = (http).XMLHttpRequest; -global.alert = dialogs.alert; \ No newline at end of file +global.alert = dialogs.alert; + +export function Deprecated(target: Object, key?: string | symbol, descriptor?: any) { + if (descriptor) { + var originalMethod = descriptor.value; + + descriptor.value = function (...args: any[]) { + console.log(`${key} is deprecated`); + + return originalMethod.apply(this, args); + } + + return descriptor; + } else { + + console.log(`${(target && (target).name || target)}} is deprecated`); + return target; + } +} + +global.Deprecated = Deprecated; \ No newline at end of file