1

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!?

7
  • Any reason your module system isn't set to commonjs? Commented Jan 15, 2016 at 17:16
  • @AdamTuliper-MSFT Do you mean in tsconfig? There it is setted to commonjs. Commented Jan 15, 2016 at 17:18
  • In the typescript config image above it is set to none. Not sure if it helps but seems inconsistent. Commented Jan 15, 2016 at 17:20
  • @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. Commented Jan 15, 2016 at 17:22
  • @AdamTuliper-MSFT Thanks! Commented Jan 15, 2016 at 17:41

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

5 Comments

email me adamt at microsoft if you want to share project, I'll check it out. you should be able to just add the files and it works (no virtual stuff required). What type off project is it? I can try a basic repro on my end. If its ASP.NET read: github.com/Microsoft/TypeScript/wiki/…
The out of the box functionality in Visual Studio 2015 is just working with included asp.net 5 web project templates. But what if I don't use these templates? There must be another option to get that functionalities!?
Drag your .ts file into one of your html files. Load up Fiddler or the browser and run your app. Note that it should get served. Enable all of your files in Visual Studio (3rd icon from the right above in the image, ie to the left of the wrench) and you should see your .ts file listed there. I jsut tested with an MVC 5 project brought over to VS 2015 from 2013. The entire process was this: 1. create new mvc 5 app in VS 2013. Bring it into VS 2015. Add a typescript file. I get a prompt about searching for typescript typings (ie do you want the angular definitions, etc) to which I said no.
I dragged the .ts file into an html page and it automatically showed up as .js. I then right clicked and added another typescript file. I refreshed my project view and immediately my .js file showed up as well.
I removed the tsconfig.json file and now it works. When I'm adding a new ts file and put some code in, after savinf the js file shows up. But the js file is not included in project. And it doesn't look like in the picture below. Anyway, it is working for me now! Thank you so much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.