Generate equivalent string constants

Create issue
Issue #106 new
Harel Mazor created an issue

First of all I would like to say that this is a great project, keep up the good work.

I hate magic strings - in order to reduce those I create small classes of constant string values like so (this also applies to numbers):

public static class Roles
        public const string MANAGER = "Manager";
        public const string CREATIVE = "Creative";
        public const string USER = "User";

It would be great if I could mark those classes with [TsClass] or [TsConstnats] so that typelite will create a ts class with static public fields with these constants.

export class Roles {
        public static MANAGER = "Manager";
        public static CREATIVE = "Creative";
        public static USER= "User";

I know that enums are preferred but sometimes you don't have a choice...

Comments (2)

  1. Diego Fulgueira

    The idea should be generalized to all static properties, and be optionally available with a flag.

  2. Harel Mazor reporter

    This issue was opened two years ago without any comment from the maintainers. I would say that this project is abandoned, which is unfortunate since the concept is something that is very useful and reduces typo errors...

  3. Log in to comment