Example #1
0
        public override string WriteTypeScript(CodeConversionOptions options, Context context)
        {
            context = context.Clone();
            context.GenericTypeParameters = GenericTypeParameters;

            // keywords
            return("export ".If(options.Export) + "interface "
                   // name
                   + Name.TransformIf(options.RemoveInterfacePrefix, StringUtilities.RemoveInterfacePrefix)
                   // generic type parameters
                   + ("<" + GenericTypeParameters.ToCommaSepratedList() + ">").If(GenericTypeParameters.Any())
                   // base types
                   + (" extends " + BaseTypes.WriteTypeScript(options, context).ToCommaSepratedList()).If(BaseTypes.Any())
                   // body
                   + " {" + NewLine
                   // fields
                   + Fields.WriteTypeScript(options, context).Indent(options.UseTabs, options.TabSize).LineByLine() + NewLine
                   + "}");
        }
Example #2
0
 public string WriteTypeScript(CodeConversionOptions options)
 => "export ".If(options.Export) + "interface " + Name.RemoveInterfacePrefix() + ("<" + GenericTypeParameters.ToCommaSepratedList() + ">").If(GenericTypeParameters.Any()) + (" extends " + BaseTypes.Select(e => e.WriteTypeScript()).ToCommaSepratedList()).If(BaseTypes.Any()) + " {" + NewLine
 + Fields.Select(f => f.WriteTypeScript()).Indent(options.UseTabs, options.TabSize).LineByLine() + NewLine
 + "}";