There is a suggestion on GitHub to implement a feature in tsc
that would mark compiled files as readonly. However, it has been deemed not feasible and will not be pursued. As someone who tends to accidentally modify compiled files instead of the source files, I am left wondering what my options are.
Unfortunately, my project structure is less than ideal (and cannot be changed for existing projects), with compiled .js
files residing in the same folder as the .ts
files:
|-- file.ts
|-- file.js
|-- another.ts
|-- another.js
|-- folder
|-- file.ts
|-- file.js
|-- non-typescript.js <-- not read-only
In the suggested solution, someone proposed using a different color for
.js
files compared to.ts
files, but this wouldn't work for me as I also have standalone Javascript files in my projects (not compiled by TypeScript).Although VS Code offers a readonly feature, it's difficult to use when there are editable JS files mixed with the generated ones.
I am open to exploring any IDE/environment build tools (such as WebPack or Rollup), although my experience with them is limited. The majority of my projects are Chrome extensions or static web pages that do not currently undergo packing - we simply compile and use the resulting .js
files.