CSharpToTypeScript icon indicating copy to clipboard operation
CSharpToTypeScript copied to clipboard

Const strings are not converted

Open matthew-dean opened this issue 1 year ago • 0 comments

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.

matthew-dean avatar Sep 19 '23 00:09 matthew-dean