Can I restrict a function to be pure in TypeScript?

跟風遠走 提交于 2019-12-08 16:10:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!