This project is read-only.

Should TypeScript projects include the generated .js files?

Topics: General
Nov 16, 2012 at 7:25 PM
Edited Nov 16, 2012 at 7:29 PM

I think not. Only .ts files should be included in the .csproj file.

I'm talking about this:

<Content Include="app.js">

I look at generated .js and .map files the same way I look at generated .dlls in the bin folder. These files should be considered build output only and not included in source control systems.

Many source control systems (TFS included) will set these files to readonly when the project is checked in and suddenly you get compiler errors on rebuild.

1>EXEC : error : EPERM, operation not permitted 'D:\TFS\TypeScriptHTMLApp1\app.js'
1>      at Object.fs.openSync (fs.js:338:18)
1>      at IO.createFile (C:\Program Files\nodejs\node_modules\typescript\bin\tsc.js:23909:30)
1>      at TypeScriptCompiler.emit (C:\Program Files\nodejs\node_modules\typescript\bin\tsc.js:23324:31)
1>      at BatchCompiler.compile (C:\Program Files\nodejs\node_modules\typescript\bin\tsc.js:24382:26)
1>      at BatchCompiler.batchCompile (C:\Program Files\nodejs\node_modules\typescript\bin\tsc.js:24671:18)
1>      at Object. (C:\Program Files\nodejs\node_modules\typescript\bin\tsc.js:24680:7)
1>      at Module._compile (module.js:449:26)
1>      at Object.Module._extensions..js (module.js:467:10)
1>      at Module.load (module.js:356:32)
1>      at Function.Module._load (module.js:312:12)
1>D:\TFS\TypeScriptHTMLApp1\TypeScriptHTMLApp1.csproj(74,5): error MSB3073: The command "tsc --sourcemap "D:\TFS\TypeScriptHTMLApp1\app.ts"" exited with code 1.

Please fix and/or advise.

And thanks for the great work!

Nov 16, 2012 at 8:16 PM
Edited Nov 16, 2012 at 8:17 PM

Furthermore, it appears that in the 0.8.1 release, we no longer can remove the dependent .js file from the TypeScript project because VS 2012 will crash every time when you start with debugging if you remove or delete the generated .js file.

This is pretty annoying because that means that I now have to check out my entire project just to rebuild it.

Nov 23, 2012 at 1:22 PM

I agree with you. Having the same annoyance.

Nov 26, 2012 at 5:19 PM

We'll be releasing a bug fix release shortly that will help with the crashes, though we'll still have the limitation that the .js files will need to be part of the project.

Ultimately, we don't want to have to require them in the project.  Like you point out, they interact with source control like TFS and you don't really want to have to see them if you don't want to. 

Feb 14, 2013 at 8:58 PM

I have a need to include the .js file in the project because the generated .js is an embedded resource for a web control. We should definitely have the option for including the generated .js file in the project and having it work appropriately with TFS, much the same way that that code behind files generated for aspx pages behave with regards to the project inclusion and TFS checkin/checkout.

Please do not remove them from the project by default but please do insure that they check out when the built file is different. It would be nice if the build is done somewhere temporary (memory?) and then compared with the on disk file so that a checkout is not done on every single build of the project.
Oct 9, 2013 at 9:00 PM
I'd prefer if the generated files were NOT in the project.

However, the "Publish..." feature won't pick up the .js files if the project has no knowledge of the .js files.
I'm willing to include the files to simplify the publish process.
But, if the files are included, I need to manually check them out before making edits (which is annoying).

So, I can either have a manual "Publish..." experience; or I can have a manual "Check Out for Edit..." experience. I'm opting for the manual "Check Out for Edit..." experience, but it's a lesser of two evils. :(

In the best of all worlds, I would have a configuration option to "Attach generated files to project."
A configurable default "Build Action" is available for each generated file-type (".js" and ""). (Personally, I want the ".js" file to use "Content" and the "" file to use "None".)
If the configuration option is turned on:
  • when generated, generated files will be added to the project, if necessary
  • when generated, generated files will be checked-out, if necessary
  • when added to the project, generated files will be sub-items to the original .ts file (using DependentUpon).
  • when added to the project, generated files will use the configurable "Build Action"
If the configuration option is turned off, none of these steps are necessary.
Oct 9, 2013 at 9:29 PM
Publish should pick up the generated .js files.. what kind of project do you see this in?

The order of the targets in the csproj file matters... and we did fix a bug recently. If you open a bug and upload you're csproj file, we should be able to help.
Oct 9, 2013 at 10:00 PM