Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript does not compile if it is located in subfolder?

I have two projects in VS2012. One created as a "HTML App with Typescript" and one (a DLL) where I added a Typescript file to an existing project (I added the BeforeBuild Target to the existing project).

When I compile the HTML App project it compiles the TS to JS just fine and add the JS as content.

When I compile my DLL I do not get any results form the TSC...neither in the folder I put the TS file nor in the root or any other folder...I do not get any errors or other hints what could be wrong.

In the properties of both projects the TS file shows as:

BuildAction: TypeScriptCompile
Copy to output....: Do not copy

In the .csproj file the section inside the item group looks like:

<ItemGroup>
...(Lots of other "EmbeddedResources" in this ItemGroup)
    <TypeScriptCompile Include="C-DCommunication\ClientBin\CDEHTML5\cdeUX5.ts" />
    <Content Include="C-DCommunication\ClientBin\CDEHTML5\cdeUX5.js">
      <DependentUpon>cdeUX5.ts</DependentUpon>
    </Content>
...(more files in my ItemGroup)
</ItemGroup>

It looks to me like the TSC compiler does not parse the path correctly. Can somebody verify?

Thanks

like image 968
Chris Muench Avatar asked Nov 13 '22 17:11

Chris Muench


1 Answers

When I add TypeScript to an existing project, I tend to add the following to my project file:

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

Source

But if you use the Web Essentials Visual Studio extension, it will compile the TypeScript to JavaScript on save, which I find gives a better flow to development.

like image 166
Fenton Avatar answered Nov 15 '22 07:11

Fenton