Enums should go in a .ts file, not .d.ts

Issue #17 resolved
tmmueller
created an issue

The current implementation puts enums in TypeLite.d.ts with everything else. This allows the TypeScript to compile, but it does not generate any JavaScript code, so you cannot actually use the enums. Enums should go into a .ts file instead so that other TypeScript code can use them, and the generated JavaScript code will work.

Comments (3)

  1. Lukas Kabrt repo owner

    Added support for generating enums and classes into separate files. Requires modification of Typescript.tt

     <#@include file="Manager.ttinclude"#>
    <# var manager = Manager.Create(Host, GenerationEnvironment); #>
    
    <# var ts = TypeScript.Definitions()
            .WithReference("Enums.ts")
            .ForLoadedAssemblies();
    #>
    
    <#= ts.Generate(TsGeneratorOutput.Classes) #>
    
    <# manager.StartNewFile("Enums.ts"); #>
    <#= ts.Generate(TsGeneratorOutput.Enums) #>
    <# manager.EndBlock(); #>
    <# manager.Process(true); #>
    
  2. Log in to comment