Skip to content
This repository has been archived by the owner on May 21, 2018. It is now read-only.

Use declare namespace syntax when possible #62

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions T4TS.Tests/Output/ModuleOutputAppenderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ public void TypescriptVersion090YieldsDeclareModule()
appender.AppendOutput(module);
Assert.IsTrue(sb.ToString().StartsWith("declare module "));
}

[TestMethod]
public void TypescriptVersion150YieldsDeclareNamespace()
{
var sb = new StringBuilder();
var module = new TypeScriptModule
{
QualifiedName = "Foo"
};

var appender = new ModuleOutputAppender(sb, 0, new Settings
{
CompatibilityVersion = new Version(1, 5, 0)
});

appender.AppendOutput(module);
Assert.IsTrue(sb.ToString().StartsWith("declare namespace "));
}

[TestMethod]
public void DefaultTypescriptVersionYieldsDeclareModule()
Expand Down
4 changes: 3 additions & 1 deletion T4TS/Outputs/ModuleOutputAppender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ private void BeginModule(TypeScriptModule module)
{
if (Settings.CompatibilityVersion != null && Settings.CompatibilityVersion < new Version(0, 9, 0))
Output.Append("module ");
else
else if (Settings.CompatibilityVersion == null || Settings.CompatibilityVersion < new Version(1, 5, 0))
Output.Append("declare module ");
else
Output.Append("declare namespace ");

Output.Append(module.QualifiedName);
Output.AppendLine(" {");
Expand Down