问题
Is there a way to allow a function to be pure only (thus not accepting the function to be non pure) in TypeScript? If yes, which?
回答1:
You might be able to write a few TSLint rules to catch most of the common cases (access to outside variables, for example), but checking something like that is nigh impossible, so there's no way to actually know 100%.
You (and your team) still have to be disciplined.
来源:https://stackoverflow.com/questions/45834108/can-i-restrict-a-function-to-be-pure-in-typescript