Comment on page
@Deprecated
Deprecated decorator allows to identify method as deprecated by printing deprecation message to the console or throwing an exception
The deprecated decorator prints deprecation message for each usage of the the annotated method. Also, the deprecation decorator allows to throw an exception whenever the method use.
@Derprecated interface
export function Deprecated();
export function Deprecated(msg: string);
export function Deprecated(throwException: boolean);
export function Deprecated(msg: string, throwException: boolean);
The default message is of the pattern:
%s.%s is deprecated
while first string is the class name and the second string is the method name, for example Utils.guid
will identify the method guid
under Utils
class is deprecated.utils.class.ts
export class Utils{
@Deprecated()
public static guid(){
//some old code
}
}
The message pattern can be change by passing the wanted pattern to the decorator:
utils.class.ts
export class Utils{
@Deprecated("Method %s.%s is deprecated please use NewUtils.guid instead")
public static guid(){
//some old code
}
}
Last modified 5yr ago