<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import require = require('collisionExportsRequireAndAlias_file1'); // Error
//!!! Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of an external module.
import exports = require('collisionExportsRequireAndAlias_file11'); // Error
//!!! Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of an external module."><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-en">require</span> <span class="pl-c1">=</span> require<span class="pl-kos">(</span><span class="pl-s">'collisionExportsRequireAndAlias_file1'</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// Error</span>
<span class="pl-c">//!!! Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of an external module.</span>
<span class="pl-k">import</span> <span class="pl-s1">exports</span> <span class="pl-c1">=</span> require<span class="pl-kos">(</span><span class="pl-s">'collisionExportsRequireAndAlias_file11'</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// Error</span>
<span class="pl-c">//!!! Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of an external module.</span></pre></div>
<p dir="auto">Expected: errors above<br>
Actual: no errors</p>
<p dir="auto">See related testcases for other examples of where this is an error linked in TC ID field:<br>
collisionExportsRequireAndClass.errors.txt<br>
collisionExportsRequireAndEnum.errors.txt<br>
collisionExportsRequireAndFunction.errors.txt<br>
collisionExportsRequireAndModule.errors.txt<br>
collisionExportsRequireAndVar.errors.txt<br>
collisionRestParameterArrowFunctions.errors.txt</p>
<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">1.8.x</p>
<p dir="auto"><strong>Code</strong></p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// A self-contained demonstration of the problem follows...
function createDefaultProperties(): { [name: string]: any } {

    const startTime = Date.now();
    let eventCounter = 0;

    return {
        get ['common.sequenceId']() { return eventCounter++; },
        get timestamp() { return new Date(); },
        get ['common.timesincesessionstart']() { return Date.now() - startTime; }
    };
}"><pre class="notranslate"><span class="pl-c">// A self-contained demonstration of the problem follows...</span>
<span class="pl-k">function</span> <span class="pl-en">createDefaultProperties</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-kos">{</span> <span class="pl-kos">[</span><span class="pl-s1">name</span>: <span class="pl-smi">string</span><span class="pl-kos">]</span>: <span class="pl-smi">any</span> <span class="pl-kos">}</span> <span class="pl-kos">{</span>

    <span class="pl-k">const</span> <span class="pl-s1">startTime</span> <span class="pl-c1">=</span> <span class="pl-smi">Date</span><span class="pl-kos">.</span><span class="pl-en">now</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">let</span> <span class="pl-s1">eventCounter</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">;</span>

    <span class="pl-k">return</span> <span class="pl-kos">{</span>
        <span class="pl-k">get</span> <span class="pl-kos">[</span><span class="pl-s">'common.sequenceId'</span><span class="pl-kos">]</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">eventCounter</span><span class="pl-c1">++</span><span class="pl-kos">;</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
        <span class="pl-k">get</span> <span class="pl-en">timestamp</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-k">new</span> <span class="pl-smi">Date</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
        <span class="pl-k">get</span> <span class="pl-kos">[</span><span class="pl-s">'common.timesincesessionstart'</span><span class="pl-kos">]</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-smi">Date</span><span class="pl-kos">.</span><span class="pl-en">now</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">-</span> <span class="pl-s1">startTime</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
    <span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<ul dir="auto">
<li>open playground website</li>
<li>paste code above</li>
<li>it crashes like so:</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Object {stack: &quot;TypeError: Cannot read property 'declarations' of …script/common/lib/typescriptServices.js:19:13310)&quot;, message: &quot;TypeError: Cannot read property 'declarations' of undefined&quot;}
message
:
&quot;TypeError: Cannot read property 'declarations' of undefined&quot;
stack
:
&quot;TypeError: Cannot read property 'declarations' of undefined↵    at e.checkNode (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/typescriptWorker2.js:1:30909)↵    at t.e._checkNodeOrToken (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/typescriptWorker2.js:2:2107)↵    at t.e._visit (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/typescriptWorker2.js:2:1801)↵    at https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/typescriptWorker2.js:2:1853↵    at r (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/lib/typescriptServices.js:19:10966)↵    at Object.i [as forEachChild] (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/lib/typescriptServices.js:19:14002)↵    at t.e._visit (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/typescriptWorker2.js:2:1824)↵    at https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/typescriptWorker2.js:2:1853↵    at a (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/lib/typescriptServices.js:19:11081)↵    at Object.i [as forEachChild] (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/lib/typescriptServices.js:19:13310)&quot;
__proto__
:
Object"><pre class="notranslate"><code class="notranslate">Object {stack: "TypeError: Cannot read property 'declarations' of …script/common/lib/typescriptServices.js:19:13310)", message: "TypeError: Cannot read property 'declarations' of undefined"}
message
:
"TypeError: Cannot read property 'declarations' of undefined"
stack
:
"TypeError: Cannot read property 'declarations' of undefined↵    at e.checkNode (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/typescriptWorker2.js:1:30909)↵    at t.e._checkNodeOrToken (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/typescriptWorker2.js:2:2107)↵    at t.e._visit (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/typescriptWorker2.js:2:1801)↵    at https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/typescriptWorker2.js:2:1853↵    at r (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/lib/typescriptServices.js:19:10966)↵    at Object.i [as forEachChild] (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/lib/typescriptServices.js:19:14002)↵    at t.e._visit (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/typescriptWorker2.js:2:1824)↵    at https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/typescriptWorker2.js:2:1853↵    at a (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/lib/typescriptServices.js:19:11081)↵    at Object.i [as forEachChild] (https://www.typescriptlang.org/play/Script/vs/languages/typescript/common/lib/typescriptServices.js:19:13310)"
__proto__
:
Object
</code></pre></div>