javascripttypescriptfunctionpure-function

Can I restrict a function to be pure in TypeScript?


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?


Solution

  • 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.