public void ModuleOutputAppenderRespectsCompatibilityVersion() { var sb = new StringBuilder(); var module = new TypeScriptModule { QualifiedName = "Foo" }; var settings = new Settings(); var appender = new ModuleOutputAppender(sb, 0, settings); settings.CompatibilityVersion = new Version(0, 8, 3); appender.AppendOutput(module); Assert.IsTrue(sb.ToString().StartsWith("module")); sb.Clear(); settings.CompatibilityVersion = new Version(0, 9, 0); appender.AppendOutput(module); Assert.IsTrue(sb.ToString().StartsWith("declare module")); sb.Clear(); settings.CompatibilityVersion = null; appender.AppendOutput(module); Assert.IsTrue(sb.ToString().StartsWith("declare module")); }
public void TypescriptVersion083YieldsModule() { Version version = new Version(0, 8, 3); var sb = new StringBuilder(); var module = new TypeScriptModule { QualifiedName = "Foo" }; var appender = new ModuleOutputAppender( new OutputSettings { CompatibilityVersion = version }, new TypeContext(new TypeContext.Settings() { CompatibilityVersion = version })); appender.AppendOutput( sb, 0, module); Assert.IsTrue(sb.ToString().StartsWith("module ")); }
public void DefaultTypescriptVersionYieldsDeclareModule() { var sb = new StringBuilder(); var module = new TypeScriptModule { QualifiedName = "Foo" }; var appender = new ModuleOutputAppender(sb, 0, new Settings { CompatibilityVersion = null }); appender.AppendOutput(module); Assert.IsTrue(sb.ToString().StartsWith("declare module ")); }
public void TypescriptVersion083YieldsModule() { var sb = new StringBuilder(); var module = new TypeScriptModule { QualifiedName = "Foo" }; var appender = new ModuleOutputAppender(sb, 0, new Settings { CompatibilityVersion = new Version(0, 8, 3) }); appender.AppendOutput(module); Assert.IsTrue(sb.ToString().StartsWith("module ")); }
public static string GetOutput(List<TypeScriptModule> modules, Settings settings) { var output = new StringBuilder(); output.AppendLine("/****************************************************************************"); output.AppendLine(" Generated by T4TS.tt - don't make any changes in this file"); output.AppendLine("****************************************************************************/"); var moduleAppender = new ModuleOutputAppender(output, 0, settings); foreach (var module in modules) { output.AppendLine(); moduleAppender.AppendOutput(module); } return output.ToString(); }
public void TypescriptVersion090YieldsDeclareModule() { var sb = new StringBuilder(); var module = new TypeScriptModule { QualifiedName = "Foo" }; var appender = new ModuleOutputAppender( new OutputSettings { CompatibilityVersion = new Version(0, 9, 0) }, new TypeContext()); appender.AppendOutput( sb, 0, module); Assert.IsTrue(sb.ToString().StartsWith("declare module ")); }