I've just discovered that, with WebEssentials 2013 I can right-click a CS file and choose Web Essentials->Create Typescript Intellisense File.
At the moment, all the generated interfaces are put in module "server". How can I change this?
This is a great question (where I didn't know the answer for) so I searched in the code from Web Essentials and yes this is possible! You need to do the following:
Create a new .cs file with the following code (don't do It in the same file you are generating definitions from or somehow it will throw an error).
[System.AttributeUsage(AttributeTargets.Class)]
sealed class TypeScriptModuleAttribute : Attribute
{
private readonly string moduleName;
public TypeScriptModuleAttribute(string moduleName)
{
this.moduleName = moduleName;
}
}
Now apply it to a class:
[TypeScriptModule("foo")]
public class TestClass
{
<snip>
}
It will generate something like this:
declare module foo {
interface TestClass {
}
}
If you are interested, you can find the code where Web Essentials does this here: link and the code for writing the file here: link2