public string ToString(int indent)
        {
            var stringBuilder = new IndentAwareStringBuilder
            {
                Indent = indent
            };

            stringBuilder.AppendLine(Statement);

            return(stringBuilder.ToString());
        }
        private static void AppendNewLineIfApplicable(ITypeScriptCode nextChild, ITypeScriptCode child,
                                                      bool isThisTheLastChild, IndentAwareStringBuilder stringBuilder)
        {
            var isNextChildDifferent     = nextChild?.GetType() != child.GetType();
            var isNextChildABlock        = nextChild is TypeScriptBlock;
            var isNextChildANonElseBlock = isNextChildABlock &&
                                           ((TypeScriptBlock)nextChild).Outer != "else";
            var isNextChildFunctionBlock = isNextChildABlock &&
                                           ((TypeScriptBlock)nextChild).IsFunctionBlock;

            if ((isNextChildDifferent || isNextChildANonElseBlock) &&
                !isThisTheLastChild && !isNextChildFunctionBlock)
            {
                stringBuilder.AppendLine(string.Empty);
            }
        }
        public string ToString(int indent)
        {
            var stringBuilder = new IndentAwareStringBuilder
            {
                Indent = indent
            };

            if (!string.IsNullOrEmpty(Outer))
            {
                var outerPaddingString = Outer.EndsWith("(") ? string.Empty : " ";
                stringBuilder.AppendLine($"{Outer}{outerPaddingString}{{");
            }
            else
            {
                stringBuilder.AppendLine($"{{");
            }

            for (var c = 0; c < Children.Count; c++)
            {
                var child = Children[c];

                var childIndent = stringBuilder.Indent + IndentPerLevel;
                var childString = child.ToString(childIndent);

                stringBuilder.AppendWithoutIndent(childString);

                var nextChild          = c < Children.Count - 1 ? Children[c + 1] : null;
                var isThisTheLastChild = c == Children.Count - 1;

                AppendNewLineIfApplicable(nextChild, child, isThisTheLastChild, stringBuilder);
            }

            var blockEndString = IsFunctionBlock ? "})" : "}";

            stringBuilder.AppendLine($"{blockEndString}{TerminationString}");

            return(stringBuilder.ToString());
        }