Generated * .js from * .ts in Visual Studio 2015

When I add a * .ts file in Visual Studio 2015, and this compiles, the * .js file is not the * .ts file code. It is simply located in a folder and is not part of the visual studio project.

Is it design or am I breaking something in my project?

If it is by design, what is the motivation? (If I want to look at the file, I have to show the hidden files and, finally, click the update button ...)

+4
source share
3 answers

This is by design - the JavaScript file is an assembly artifact, like a DLL.

The idea is that you test your TypeScript code and allow the build server to create your JavaScript files. Although you can work in Debug mode, the build server can generate them in Release mode, which can include more optimizations.

+5
source

I do not know whether it is intentional or not.

If you want to include JavaScript files in your project, you need to manually edit the project file. Open it in Notepad (or in your favorite text editor) and follow these steps:

  • Look for

<Content Include="Scripts\yourfile.ts" />

  1. Change to

<Content Include="Scripts\yourfile.js"> <DependentUpon>yourfile.ts</DependentUpon> </Content>

The JavaScript file should now be drawn in.

You need you to use Visual Studio to publish your project for deployment.

+3
source

If you want to change the output folder of the .js file, consider adding the tsconf.json file to the source folder. This way you can configure where the output .js files are output.

For instance:

{ "compilerOptions": { "target": "es5", "out": "www/scripts/appBundle.js", "sourceMap": true, "removeComments": true, "sourceRoot": "/" } }

The documentation for tsconfig.json can be found on github on this page.

0
source

All Articles