How can remove references on --declaration file ?

Topics: General, Language Specification
Nov 15, 2013 at 8:33 AM
Edited Nov 15, 2013 at 8:34 AM
While using --declaration option on the compiler, the emitted output is in ex.:
/// <reference path="Scripts/typings/jquery/jquery.d.ts" />

interface IMyInterface {
   ....
}
but I don't want the comment reference because I am not sure about the location of jquery.d.ts on the destination site and I am not sure about the destination of this .d.ts and his relative position with jquery.

At this time, every time I compile the project I need to remove manually this comment rows.
I'd like to have a compiler option for this, in ex. --noIncudeReferences or similar

Thanks
Gabriele
Nov 15, 2013 at 12:07 PM
At this time, every time I compile the project I need to remove manually this comment rows.

If you're using Visual Studio to build your project, you can use following inline build task to avoid manual removing:
    <UsingTask TaskName="RemoveLines" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
    <ParameterGroup>
      <SourceFile ParameterType="System.String" Required="true" />
      <StartsWith ParameterType="System.String" Required="true" />
    </ParameterGroup>
    <Task>
      <Code Type="Fragment" Language="cs">
         <![CDATA[
             var lines = File.ReadAllLines(SourceFile);
             var linesOut = new System.Collections.Generic.List<string>();
             foreach(var l in lines) if(!l.StartsWith(StartsWith)) linesOut.Add(l);
             File.WriteAllLines(SourceFile, linesOut);
            ]]>
     </Code>
    </Task>
  </UsingTask>
and then :
  <Target Name="AfterBuild">
    <RemoveLines SourceFile="$(ProjectDir)foobar.d.ts" StartsWith="/// &lt;reference" ></RemoveLines>
  </Target>
And, yes, compiler option like "--omitReferences" might be helpful
Nov 15, 2013 at 12:47 PM
Thank you very much!
your "Workaround" "works" fine!