-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For internal use
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Logger } from './logger/Logger'; | ||
const logger: Logger = Logger.instance(); | ||
|
||
/** | ||
* Logs a deprecation warning for the decorated class method | ||
* @private | ||
* @param {string} [message] Method deprecation message | ||
*/ | ||
export function deprecated<T extends Function>(message?: string): MethodDecorator | ||
{ | ||
return function(target: T, key: string, descriptor: PropertyDescriptor): PropertyDescriptor | ||
{ | ||
if (!descriptor) descriptor = Object.getOwnPropertyDescriptor(target, key); | ||
const original: any = descriptor.value; | ||
descriptor.value = function(...args: any[]): any | ||
{ | ||
logger.warn('Deprecation', message || `${target.constructor.name}#${key}() is deprecated and will be removed in a future release.`); | ||
return original.apply(this, args); | ||
}; | ||
return descriptor; | ||
}; | ||
} |