1

Is it possible to add a TypeScript file to a non-TypeScript project in Visual Studio 2012? I have the latest (0.8.3.1) version of TypeScript installed along with Web Essentials 2012. If I create a new TypeScript project in VS and add a new item, the TypeScript file template comes up. However, if I try to add a new item in any other project type (web site, whatever) the TypeScript template is not an option.

A workaround is just to add any type of file and rename it manually to *.ts, however, you then lose the ability to nest your generated .js file within the .ts file in Visual Studio (which can be important if you have a lot of .ts files!).

2
  • in a non-typescript project, the other project wouldn't know what to do with a typescript file, nor understand the nesting. This is a general thing, you can't compile a c# file in a vb project, because it doesn't know what it is. what are you trying to do? Commented Jun 14, 2013 at 19:26
  • 1
    I have existing C# web projects and I'd like to add some TypeScript assets to those projects (while taking advantage of the visual nesting of the compiled .js files that come with the TypeScript plugin). Commented Jun 14, 2013 at 19:49

3 Answers 3

3

My experience has been that I can add .ts files and .d.ts files to web c# projects and they compile.

I have not found 'add typescript' file on the add context menu but I have found you can add a text file .ts or .d.ts and it is recognised. You may have to amend the compile action to 'TypescriptCompile'.

Apart from that and some debugging funnies I have found TypeScript to be one of the cleverest things around...awesome in fact

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

1 Comment

This is true, however, you lose the ability to have the compiled .js and .min.js files nested under your .ts file in this case (if you are using Web Essentials 2012).
2

It's actually very simple: in the Solution Explorer, right click the folder you want and select Add > JavaScript File. Then, in the dialog to name it, just name it with a .ts extension and Visual Studio will do the rest.

Comments

0

I also experienced the same issue as Rob Lauer initially. However, after updating Web Essentials 2012 to the latest release (2.9 at the moment) the issue has been resolved and I do get the nested .js files under the .ts automatically in a non-TypeScript project.

The Web Essentials 2012 changelog lists "Fixed TypeScript compiler issue" for release 2.9: http://vswebessentials.com/changelog

Comments

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.