1
votes

In my visual studio 2015 project I created a typescript file file1.ts. I have also a tsconfig.json file in my project root folder. I installed tsc globally via npm. I also installed typescript for visual studio from here: https://www.microsoft.com/en-us/download/details.aspx?id=48593

But when I'm compiling my project, I don't get any .js file from my .ts file. But I got a Typescript Virtual Project. After reading a lot of posts here in stackoverflow, I tried a lot to find the problem. Some people posted screenshots where you can see, that they have "Typescript Options" in Project Properties window like here:

enter image description here

The typescript virtual project looks like:

enter image description here

In the .ts file I use some example code:

class Startup {
    public static main(): number {
        console.log('Hello World');
        return 0;
    }
}

And the tsconfig.json code is:

{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitAny": true,
    "removeComments": true,
    "preserveConstEnums": true,
    "sourceMap": true
  }
}

What do I have to do to let the compiler create .js files from my .ts files of my project?

EDIT:

I know in Visual Studio 2015 it is working out of the box if you use asp.net 5 project templates. But I have an existing project and it isn't working there. So there must be an option to get this functionality for existing projects!?

1
Any reason your module system isn't set to commonjs?Adam Tuliper
@AdamTuliper-MSFT Do you mean in tsconfig? There it is setted to commonjs.CPA
In the typescript config image above it is set to none. Not sure if it helps but seems inconsistent.Adam Tuliper
@AdamTuliper-MSFT Ah, no, the screenshot above is not from me. I posted this because I don't have such settings in my project settings. And I don't know why.CPA
@AdamTuliper-MSFT Thanks!CPA

1 Answers

3
votes

You don't need any of that IF you are using Visual Studio 2015 its out of the box as long as you are using at least RTM version of VS 2015. I'll assume you are since that was the extension page you posted :)

For example - just create a new ASP.NET 5 project, drop in a .ts file, add some code. Notice my typescript file here shows the .ts and its processed .js file underneath it. The npm, add-in install, etc are all unncessary if using 2015, it is handled out of the box.

Note that for MVC 5 projects, it doesn't show up quite as nice. Click the "Show all files" icon which is the third from the right icon below and then you'll see your .js file after you've added a .ts file. Mine appeared as soon as I refreshed the project view (ensure you are clicking on your project and then you'll see the refresh icon show up in solution explorer)

enter image description here