Skip to content

Instantly share code, notes, and snippets.

@Klerith
Last active August 26, 2024 02:18
Show Gist options
  • Save Klerith/c4bd6ddc72362ac35b68a0727294ebdc to your computer and use it in GitHub Desktop.
Save Klerith/c4bd6ddc72362ac35b68a0727294ebdc to your computer and use it in GitHub Desktop.
Deprecated Method - Decorador

@Deprecated - Method Decorator

En la definición del método, se puede marcar como obsoleto (deprecated) con la justificación. Esto ayudará a que otros developers sepán que deben de utilizar ya la alternativa.

@Deprecated('Most use speak2 method instead')
 speak() {
      console.log(`${ this.name }, ${ this.name }!`)
 }
const Deprecated = (deprecationReason: string) => {
return (target: any, memberName: string, propertyDescriptor: PropertyDescriptor) => {
// console.log({target})
return {
get() {
const wrapperFn = (...args: any[]) => {
console.warn(`Method ${ memberName } is deprecated with reason: ${ deprecationReason }`);
//! Llamar la función propiamente con sus argumentos
propertyDescriptor.value.apply(this, args);
}
return wrapperFn;
}
}
}
}
@CHB94git
Copy link

CHB94git commented Oct 2, 2022

Gracias Fernando!

@Abraham15rivas
Copy link

excelente

@Bryansss1
Copy link

:3 <3

@atov
Copy link

atov commented Apr 24, 2023

👍

@ShewinVega
Copy link

gracias pa

@rojasadrian012
Copy link

god

@Googluu
Copy link

Googluu commented Nov 30, 2023

de lo mejor

@Googluu
Copy link

Googluu commented Nov 30, 2023

nice

@MaxC26
Copy link

MaxC26 commented Feb 16, 2024

Thanks!

@Savecoders
Copy link

Gracias

@balfaz
Copy link

balfaz commented Apr 18, 2024

👍

@lmendoza27
Copy link

Excelente, gracias

@DesarrolladorWeb-dev
Copy link

@Excel****

@balfaz
Copy link

balfaz commented Jun 7, 2024

👍🏽

@JoseManuelYC
Copy link

Gracias Profe Fernando!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment