Update: It seems the C# code generation issue, which I suspected to be of the same reason was really a ReSharper issue. But the TypeScript issue also persists on a clean Visual Studio inside a VM.
I have based my current targets file for compiling a custom DSL to a TypeScript file partialy on what is used for XAML and the ANTLR targets file shown in this stackoverflow post as an example.
The DSL compiles just fine to typescript and the final combined .js file also contains the DSL compiled code. But intellisense just doesn't seem to recognice the generated ts file (*.g.ts).
If converted to .cs compilation (instead of .ts), it also seems that intellisense only picks up the generated class if there is an partial class of the same name referenced in the project. Is because of an error in the targets files or can't intellisense pick up non partial generated classes?
The used targets file
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="MyTestSampleTask.MyTestTask" AssemblyFile="MyTestSampleTask.dll" />
<PropertyGroup>
<LoadTimeSensitiveTargets>
$(LoadTimeSensitiveTargets);
DesignGenerateMyTestSampleOutput;
</LoadTimeSensitiveTargets>
</PropertyGroup>
<PropertyGroup>
<PrepareResourcesDependsOn>
GenerateMyTestSampleOutput;
$(PrepareResourcesDependsOn)
</PrepareResourcesDependsOn>
</PropertyGroup>
<PropertyGroup>
<CoreCompileDependsOn Condition="'$(BuildingInsideVisualStudio)'=='true'">
DesignGenerateMyTestSampleOutput;
$(CoreCompileDependsOn)
</CoreCompileDependsOn>
</PropertyGroup>
<ItemGroup Condition="'$(BuildingInsideVisualStudio)'=='true'">
<AvailableItemName Include="MyTestSample" />
</ItemGroup>
<Target Name="DesignGenerateMyTestSampleOutput">
<!-- Only if we are not actually performing a compile i.e. we are in design mode -->
<CallTarget Condition="'$(BuildingProject)' != 'true'" Targets="GenerateMyTestSampleOutput" />
</Target>
<Target Name="GenerateMyTestSampleOutput" Inputs="@(MyTestSample)" Outputs="@(MyTestSample->'$(IntermediateOutputPath)%(FileName)%(Extension).g.ts')">
<MyTestTask InputFiles="@(MyTestSample)" OutputFiles="@(MyTestSample->'$(IntermediateOutputPath)%(FileName)%(Extension).g.ts')">
<Output TaskParameter="OutputFiles" ItemName="MyTestOutputFiles" />
</MyTestTask>
<ItemGroup>
<TypeScriptCompile Include="@(MyTestOutputFiles)" />
</ItemGroup>
</Target>
</Project>
Additional Informations:
The build task I use in my Test Project is not very interesting at the moment, it just takes the DSL file (must be a single line containing a valid identifier) reads it and generated a class using the read name.
public class BasicConverterTask : ITask
{
public IBuildEngine BuildEngine { get; set; }
public ITaskHost HostObject { get; set; }
[Required]
public ITaskItem[] InputFiles { get; set; }
[Output]
public ITaskItem[] OutputFiles { get; set; }
public bool Execute()
{
for (int i = 0; i < InputFiles.Length; i++)
File.WriteAllText(OutputFiles[i].ItemSpec, ProcessFile(File.ReadAllText(InputFiles[i].ItemSpec)));
return true;
}
private string ProcessFile(string input)
{
var builder = new StringBuilder();
builder.AppendLine("module TsSample {");
builder.AppendFormat("\texport class {0} {{\n", input);
builder.AppendFormat("\t\tpublic print() : string {{ return \"{0}\"; }}\n", input);
builder.AppendLine("\t}");
builder.AppendLine("}");
return builder.ToString();
}
}
The result is just a very simple ts file generated in obj/[Debug|Release] (for example with a DSL content "MySampleClass")
module TsSample {
export class MySampleClass {
public print() : string { return "MySampleClass"; }
}
}