tslint-immutable
tslint-immutable copied to clipboard
[Discussion] Are there any compile-time performance costs to have `readonly` everywhere?
Are there any compile-time performance costs to have readonly everywhere? The whole project and idea sounds super legit to me, but I'm afraid to automatically convert my whole codebase to e.g readonly everywhere. Should I be afraid?
(I understand it's more Typescript question, but still)
I have not seen any performance degradation using the reaonly keyword, but then I cannot really say that I have measured it. About a year ago I did an auto-fix of a large code base and all readonly keyword fixes was smooth but I ran into some problem with ReadonlyArray. What happened was that tsc crashed with stack overflow. There was already an issue about it on the typescript repo and I guess much has been fixed in typescript since then.
Anyway, if your setup allows for it, my advice would be to make a new branch in your project, add the linting rules, run auto-fix all (tslint --fix), and then measure the performance of tsc and compare it to the original branch. If you do, please share your results as it would be interesting to know :-).