<p dir="auto">this example works great</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function test(value: string[]| string){
    var result: string;
    if (value instanceof Array){
        result = value.join('');
    }
}"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-s1">value</span>: <span class="pl-s1">string</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-c1">|</span> <span class="pl-s1">string</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
    <span class="pl-k">var</span> <span class="pl-s1">result</span>: <span class="pl-s1">string</span><span class="pl-kos">;</span>
    <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">value</span> <span class="pl-k">instanceof</span> <span class="pl-v">Array</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
        <span class="pl-s1">result</span> <span class="pl-c1">=</span> <span class="pl-s1">value</span><span class="pl-kos">.</span><span class="pl-en">join</span><span class="pl-kos">(</span><span class="pl-s">''</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">but this</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="interface IFoo {
    value: string[] | string;
}

function bar(options: IFoo) {
    var result: string;
    if (options.value instanceof Array) {
        result = options.value.join('')
    }
}"><pre class="notranslate"><span class="pl-s1">interface</span> <span class="pl-v">IFoo</span> <span class="pl-kos">{</span>
    value: <span class="pl-s1">string</span><span class="pl-kos">[</span><span class="pl-s1"></span><span class="pl-kos">]</span> <span class="pl-c1">|</span> <span class="pl-s1">string</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">function</span> <span class="pl-en">bar</span><span class="pl-kos">(</span><span class="pl-s1">options</span>: <span class="pl-v">IFoo</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">var</span> <span class="pl-s1">result</span>: <span class="pl-s1">string</span><span class="pl-kos">;</span>
    <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">options</span><span class="pl-kos">.</span><span class="pl-c1">value</span> <span class="pl-k">instanceof</span> <span class="pl-v">Array</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-s1">result</span> <span class="pl-c1">=</span> <span class="pl-s1">options</span><span class="pl-kos">.</span><span class="pl-c1">value</span><span class="pl-kos">.</span><span class="pl-en">join</span><span class="pl-kos">(</span><span class="pl-s">''</span><span class="pl-kos">)</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">property join does not exists on type string[] | string</p>
<p dir="auto">i think i'ts compiler mistake</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="var data : { value: string | number } = { value: 'hey' };
if (typeof data.value === 'string') {
    alert(data.value.toLowerCase());  // &lt;-- type of value is undecided 
}"><pre class="notranslate"><code class="notranslate">var data : { value: string | number } = { value: 'hey' };
if (typeof data.value === 'string') {
    alert(data.value.toLowerCase());  // &lt;-- type of value is undecided 
}
</code></pre></div>