Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get Reinforced.Typings to generate "export interface" or "export enum" as output, without wrapping it in a module?

I'm using Reinforced.Typings to generate TypeScript models from my C# models. I want the models exported as the following, not wrapped in a module:

export interface IFoobar {
    someProperty: string;
    someOtherProperty: number;
}

export enum SomeEnum {
   someEnumValue = 0,
   someOtherEnumValue = 1
}

I am able to get it almost the way I want it by using the following configuration method:

public static void Configure(ConfigurationBuilder builder)
{
    builder.Global(config => config.CamelCaseForProperties()
                                   .AutoOptionalProperties());

    builder.ExportAsInterfaces(new [] { typeof(Foobar) },
                               config => config.WithPublicProperties()
                                               .AutoI()
                                               .DontIncludeToNamespace());

    builder.ExportAsEnums(new [] { typeof(SomeEnum) },
                          config => config.DontIncludeToNamespace());
}

This will create the following output, but the export keyword missing.

interface IFoobar {
    someProperty: string;
    someOtherProperty: number;
}

enum SomeEnum {
   someEnumValue = 0,
   someOtherEnumValue = 1
}

It is possible to achieve what I want? If possible I want to avoid attributes, and keep using the fluent API.

like image 204
Kvam Avatar asked Sep 20 '25 09:09

Kvam


1 Answers

Try UseModules() in global config:

builder.Global(config => config.CamelCaseForProperties()
                               .AutoOptionalProperties()
                               .UseModules());
like image 123
Coco Avatar answered Sep 22 '25 23:09

Coco