How can I generate a declarations file AND outfile?

Topics: General
May 1, 2013 at 12:36 AM
My project is successfully compiling into a single JS outfile. But I need to generate a declarations file as well. It appears the 2 don't want to happily exist in the same csproj settings file, the declaration statement is always ignored. Here is my csproj snippet:
  <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <TypeScriptTarget>ES5</TypeScriptTarget>
    <TypeScriptIncludeComments>true</TypeScriptIncludeComments>
    <TypeScriptSourceMap>false</TypeScriptSourceMap>
    <TypeScriptOutFile>../build/phaser.js</TypeScriptOutFile>
    <TypeScriptGeneratesDeclarations>../build/phaser.lib.ts</TypeScriptGeneratesDeclarations>
  </PropertyGroup>
Is there an easy way around this? I can't compile on the command-line because there are too many files to include. I tried making an args.txt which I call on the command-line, but it gets its knickers in a right twist over the ORDER of the ts files in there, i.e. you get lots of compiler errors about one TS file not being able to reference another, like it's stuck in circular dependency hell. Which is strange because it works perfectly fine from within Visual Studio.

Suggestions welcome!
Coordinator
May 1, 2013 at 5:20 PM
TypeScriptGeneratesDeclarations takes a Boolean value. so you want to set:
<TypeScriptGeneratesDeclarations>true</TypeScriptGeneratesDeclarations>


This will cause the generation of a new file ../build/phaser.d.ts in the same output directory along with ../build/phaser.js.

The compiler does not support giving a different name to the library file, the library file will always be names "out.d.ts" for output file name "out.js" and will end up in the same directory. you can always add a build event that runs after successful builds to rename the file to phaser.lib.d.ts.

for more information on how these properties work please look at the targets file under:
%programfiles(x86)%\MSBuild\Microsoft\VisualStudio\v11.0\TypeScript\Microsoft.TypeScript.targets
May 1, 2013 at 5:25 PM
Thanks, that did indeed work. Really hoping they finally expose the compiler options directly in VS.