Issue #94 resolved
Andrea Balducci
created an issue

I'm generating a .ts angular proxy for my webapi controllers, but the enums are not exported. Checked the sources and found the issue in TsGenerator.cs:321

string visibility = output == TsGeneratorOutput.Enums || (output & TsGeneratorOutput.Constants) == TsGeneratorOutput.Constants ? "export " : "";

overridden in my custom generator to

string visibility = (output & TsGeneratorOutput.Enums) == TsGeneratorOutput.Enums || (output & TsGeneratorOutput.Constants) == TsGeneratorOutput.Constants ? "export " : "";

this is my code:

        TsGenerator generator = new TsMyCustomModelGenerator();
        var ts = new TypeScriptFluent(generator);
        ts.WithTypeFormatter((type, formatter) => "I" + ((TypeLite.TsModels.TsClass)type).Name);
        ts.WithMemberFormatter((identifier) =>TextUtils.CamelCase(identifier.Name));
        // custom module wrapping!
        ts.WithModuleNameFormatter(module => string.Empty);
        generator.SetTypeVisibilityFormatter((@class, name) => true);   // export
        generator.IndentationString = "  ";

        foreach (var knownType in _knownTypes)
        {
            ts.For(knownType);
        }

        var tsModule = ts.Generate();

There's a better way to export an enum / is a bug in the base library / I need to subclass by design?

Thank you.

Comments (1)

  1. Log in to comment