I'm writting some typescript code and I would like that no other developpers can directly edit compiled files created with Typescript. Is there a way to automaticly make readonly generated files ? Or maybe to encrypt compiled files to force next devs to use typescript original files. I know if I write some comments like "Do not edit this file, use typescript version", they will not necessary be read...
2 Answers
Setting permission to prevent other developers from accessing the typescript files could be a tedious work. I suggest that you add comment on that typescript file that you want to protect from being modified so that other developers would be notified of your intention on that file.

- 29
- 4
Generally you separate your source files from your build files. Say for example you use Git you would only keep your source files in Git, not your build files. This way whenever another developer wants to work on your project they can only get the source files. They won't be able to change your build files because they do not have access to these.
Encrypting or making the files read only is not the way to go in this scenario. Educate your developers to not edit build files. And only share source files with your developers.

- 2,436
- 2
- 21
- 33
-
I wish it to be true but the thing is I'm working in a very small team and the organisation is very special. I'm permanent at the office, others aren't, but I know others developpers would go to the "easiest" way for them if one day they need to edit my code when I'm not there. So I'm afraid they edit compiled files and unsynchronised typescript files. On another side, encrypt or make difficult to read these files would have a second utility for us because compiled codes could be also share with some specific clients and to make sure that they cannot steal our company skill would be great. – Xue Fang Mar 11 '19 at 14:22
-
Encrypting these files is not possible because you'd need them unencrypted if you'd ever want to run them on your client's machine. If you want to make them difficult to read you'd want something like [UglifyJS](https://www.npmjs.com/package/uglify-js). This tool makes your Javascript ugly and minimal. This should scare any developer from trying to edit it. – Mathyn Mar 11 '19 at 14:27
-
1But please try and educate the developers. Editing the Javascript files shouldn't be the easiest way as Typescript should be much more readable. Perhaps the developers aren't educated enough on the benefits of Typescript? – Mathyn Mar 11 '19 at 14:28
-
One developper is temporary there and still at school and another one is my leader but he only comes to help when I'm really really full =) So the good thing is I can organise my code as I want but behind everyone code in his own way. – Xue Fang Mar 11 '19 at 14:41
-
This may go a bit off topic from your original question but it sounds like you only really need to educate one developer. And seeing how this developer is still at school he would be in need of education/guidance anyway. – Mathyn Mar 11 '19 at 14:50