20

I've added file1.ts and I can see there's a dependent to it - namely file1.js.

I notice that any changes I made to file1.ts - file1.js doesn't get automatically re-generated.

The only workaround I have at the moment is by calling tsc.exe - as part of pre-build event.

My question is - are there any better workaround or maybe a setting somewhere I might've missed ?

2

5 Answers 5

23

Install the Web Essentials 2012 extension in Visual Studio 2012.

It will re-generate the .js file on every save of the .ts file.

http://visualstudiogallery.msdn.microsoft.com/07d54d12-7133-4e15-becb-6f451ea3bea6

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

4 Comments

But what about the CommonJS requires() stuff? I'm not getting that in my compiled code and I have to include all the files myself.
@uosɐſ to compile your TS modules to AMD modules, you need to call the tsc compiler from a command prompt and pass the modules parameter: tsc --modules amd [list of filenames]
How do you get the same thing to work in VS 2012 web express?
For some reason it doesn't do it for me.
6

You have to add a BeforeBuild target to your ASP.NET application's CSPROJ:

<Target Name="BeforeBuild">
<Exec Command="&quot;$(PROGRAMFILES)\Microsoft SDKs\TypeScript\0.8.0.0\tsc&quot;     @(TypeScriptCompile ->'&quot;%(fullpath)&quot;', ' ')" />
</Target>

tip: edit your csproj file with notepad.

3 Comments

If you're using Visual Studio Express you need to follow this step as Web Essentials is not supported for Express versions.
TypeScript for Visual Studio 2012 is supported on Express and it includes a project type under C# called "HTML Application with TypeScript" which includes this in the CSPROJ by default.
For Typescript 0.8.1 refer to this: typescript.codeplex.com/discussions/403394
4

Support for typescript has been removed from Web Essentials 2012 v3

you now need to download typescript support directly from microsoft:

http://www.microsoft.com/en-us/download/details.aspx?id=34790

Comments

0

In Visual Studio you need to invoke the build process for your files to be generated. The playground does not use the same build system, and it triggers the compilation once the source changes, so this is why you are seeing the difference in behavior.

1 Comment

note on this - the playground's probably using the tsc.js and as such can generate on the fly
0

plug

You can use Install-Package TypeScript.Compile to add a afterbuild target that compiles all TypeScript files included in your project.

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.