AdrianWilczynski / CSharpToTypeScript

Convert C# Models, ViewModels and DTOs into their TypeScript equivalents using webapps, CLI Tool or VSCode extension. Links: https://marketplace.visualstudio.com/items?itemName=adrianwilczynski.csharp-to-typescript - https://csharptotypescript.azurewebsites.net - https://adrianwilczynski.github.io/CSharpToTypeScript/ - https://www.nuget.org/packages/CSharpToTypeScript.CLITool/
MIT License
114 stars 32 forks source link

Const strings are not converted #66

Open matthew-dean opened 1 year ago

matthew-dean commented 1 year ago

We have C# files that define what looks like dictionaries?

That is, it has code like this:

public class Foo {
  public const string AConstant = "A string constant";
  public const string AnotherConstant = "Another string constant";
}

This was converted by the plugin to a structure like this:

export interface Foo {
  aConstant: string;
  anotherConstant: string;
}

So, for one, I'm not sure how it is useful to convert the casing. In my case, I'm converting Razor templates into Vue ones, and they have bindings into these constants, so it's a matter of converting '@Foo.AnotherConstant' to Foo.AnotherConstant, but the casing conversion would make that impossible.

Secondly, of course, the values are missing. I don't understand this kind of conversion because TypeScript has classes, and classes can be used as interfaces, so why isn't the output just:

export class Foo {
  static AConstant = "A string constant";
  static AnotherConstant = "Another string constant";
}

That would be a direct representation of the class.