More flexible TsMemberTypeFormatter

Issue #58 resolved
Christian Eldam
created an issue

Currently it only receives the memberTypeName (string) and isMemberCollection (bool).

Right now I format every single type as KnockoutObservable or -Collection with a custom MemberTypeFormatter. I would like the possibility to check the property for a custom attribute, so for instance, that I can disable the knockout-formatting based on an attribute.

Comments (2)

  1. Stanley Goldman

    @aceldam

    Check this https://bitbucket.org/LukasKabrt/typelite/pull-request/22/making-typelite-better-for-me-horrible/diff

    With a custom script generator and my changes I was able to turn this enum

        [TsEnum(Module = "Enums")]
        public enum ExanpleEnum
        {
            [Description("Choice One")]
            ChoiceOne,
    
            [Description("Choice Two")]
            ChoiceTwo,
        }
    

    Into this AMD Enum implementation.

    module Enums {
        export module ExanpleEnum {
            export enum Enum {
                ChoiceOne = 0,
                ChoiceTwo = 2
            }
    
            export function describe (enumValue: Enum) {
                switch (enumValue) {
                    case Enum.ChoiceOne:
                        return "Choice One";
                    case Enum.ChoiceTwo:
                        return "Choice Two";
                    default:
                        throw Error("Unknown Enum Value");
                }
            }
        }
    }
    export = Enums;
    
  2. Log in to comment