This project is read-only.

Generated Code Warnings in the output Javascript?

Topics: General
Jan 23, 2014 at 4:27 PM
I'm architecting a Typescript application for my company now, and so far the language is really great.

However, there's one thing I wonder about, whether it's possible or not. When a project is complete on my team we usually ship it to a lesser-experienced team and it keeps being handed down the chain as it ages, and these lower teams are usually less experienced and more "hacky" developers. As such, I would love to have Typescript put a warning at the top of each generated JS file, indicating it's a generated file and will be overwritten whenever someone edits the TS file. At the moment I can't see how to do this. I would love to be able to have that warning there so that future developers don't just start hacking up the JS files whenever they run across a new bug.
Jan 23, 2014 at 5:07 PM
We try to keep the JavaScript we output as clean as possible, so we generally don't do any kind of branding of the output JavaScript.

One possibility, since the TypeScript compiler is open source, is for you to modify the piece of the compiler that does the JavaScript file generation so that the text you want is what gets put at the top of the files. Then you could make that the "blessed" version of the compiler for your organization. I think the fix should be rather small and (hopefully) easy to maintain going forward.
Jan 23, 2014 at 11:11 PM
If you're using Visual Studio and MSBuild I would consider trying to add the header in the build target in the csproj. Check this out

If you're using Grunt setting up a Grunt task should be even easier.