Andrzej Gis
Andrzej Gis

Reputation: 14306

How to work with TypeScript in an MVC application

I'm using Visual Studio 2013 to create an MVC5 application. I decided to use TypeScript for the client side. I have TypeScript installed and more or less configured. When I build the project JavaScript files appear next the TypeScript files (*.js and *js.map).

The problem is that those files are not included in the solution. I can only see them when I select "Show All Files" in Solution Explorer or browse my solution folder with file explorer.

I see 2 bad consequences:

  1. When I add a .js file to a view like that <script src="~/Scripts/Custom/Tmp.js"></script> Resharper complains "Project file expected at XYZ". However when I run the MVC application JavaScripts work fine.
  2. If the .js files are not included in the solution they won't be published and so the webpage won't work properly.

The only solution that comes to my mind is to add the files manually, but:

What's the proper way to use TypeScript in an MVC application?

Upvotes: 2

Views: 1896

Answers (1)

Ray
Ray

Reputation: 3109

My experience so far with a project just like yours is unproblematic. After working with TypeScript so much, it's become painful to look at JavaScript!

Problem 1) doesn't happen in plain VS suggesting that the issue is with ReSharper.

Problem 2) isn't. Deployment works somehow; the .js files are published but the .js.map files are not.

Upvotes: 2

Related Questions