<p dir="auto">There is a bug (TypeScript 1.4.1) in js code generation when new line is missing after end comment.</p>
<p dir="auto">To reproduce create new ts project add foo.ts:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="/*
class Foo {
    foo() {
    }
}   */"><pre class="notranslate"><span class="pl-c">/*</span>
<span class="pl-c">class Foo {</span>
<span class="pl-c">    foo() {</span>
<span class="pl-c">    }</span>
<span class="pl-c">}   */</span></pre></div>
<p dir="auto">The generated js is:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="/*
class Foo {
    foo() {
    }
/*
class Foo {
    foo() {
    }

//# sourceMappingURL=foo.js.map"><pre class="notranslate"><span class="pl-c1">/</span><span class="pl-c1">*</span>
<span class="pl-k">class</span> <span class="pl-smi">Foo</span> <span class="pl-kos">{</span>
    <span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-kos">}</span>
<span class="pl-c1">/</span><span class="pl-c1">*</span>
<span class="pl-c1">class</span> <span class="pl-smi">Foo</span> <span class="pl-kos">{</span>
    <span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-kos">}</span>

<span class="pl-c">//# sourceMappingURL=foo.js.map</span><span class="pl-kos"></span></pre></div>
<p dir="auto">If there is new line after */ it works ok.</p>
<p dir="auto">We have a large <code class="notranslate">Typescript</code> application, and sometimes we have code like</p>
<p dir="auto"><code class="notranslate">if (shouldFireNuclearMissiles)...</code></p>
<p dir="auto">while we should have written</p>
<p dir="auto"><code class="notranslate">if (shouldFireNuclearMissiles())...</code></p>
<p dir="auto">(pun intended).</p>
<p dir="auto">So forgetting to evaluate a function results in a <code class="notranslate">truthy</code> value.</p>
<p dir="auto">I forked the <code class="notranslate">tsc</code> compiler to add basic checks for this in the conditional operator, the <code class="notranslate">if-then-else</code>, <code class="notranslate">while</code>, <code class="notranslate">do</code> and <code class="notranslate">for</code> statements, and that was very easy. We found several bugs in our large code using this forked compiler.</p>
<p dir="auto">Would such a stricter compiler option (maybe even emitting warnings) be a sound idea?</p>
<p dir="auto">These automatic <code class="notranslate">truthy</code> and <code class="notranslate">falsy</code> conversions are very handy, but IMHO, for large projects, the comfort they bring does not outweigh the dangers.</p>
<p dir="auto">Most likely this idea is too much non-<code class="notranslate">Javascript</code>-like, but we're coming from sharp &amp; strongly-typed languages, so I must make this suggestion ;-)</p>
<p dir="auto">Thanks,<br>
Peter</p>
<p dir="auto">PS: I first <a href="https://github.com/Microsoft/tslint-microsoft-contrib/issues/112" data-hovercard-type="issue" data-hovercard-url="/microsoft/tslint-microsoft-contrib/issues/112/hovercard">suggested this as a TSLINT rule </a>, but from the friendly feedback I got, it seems this belongs in the compiler instead.</p>