-
-
Save tatat/de869bbe4a815802ffbeb959e9cfaf62 to your computer and use it in GitHub Desktop.
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
function FuckingPredeterminedMethodName(fuckinName: string) { | |
return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => { | |
target.__fuckingPredeterminedMethodNameCalled__ = target.__fuckingPredeterminedMethodNameCalled__ || {} | |
target.__fuckingPredeterminedMethodNameCalled__[fuckinName] = 0 | |
target[fuckinName] = function() { | |
if (++ target.__fuckingPredeterminedMethodNameCalled__[fuckinName] > 3) { | |
throw new Error('Stop it!') | |
} else { | |
console.warn(`Do not call me ${ fuckinName }.`) | |
return target[propertyKey].apply(this, arguments) | |
} | |
}; | |
}; | |
} | |
class U { | |
@FuckingPredeterminedMethodName('inu') | |
neko(): U { | |
console.log('hai.') | |
return this | |
} | |
} | |
interface U { | |
inu(): U | |
} | |
new U().inu().inu().inu().neko().inu() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment