<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">1.8.10</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="
import * as ts from &quot;typescript&quot;;

// Note: this uses ts.formatting which is part of the typescript 1.4 package but is not currently 
//       exposed in the public typescript.d.ts. The typings should be exposed in the next release. 
function format(text: string) {
    let options = getDefaultOptions();

    // Parse the source text
    let sourceFile = ts.createSourceFile(&quot;file.ts&quot;, text, ts.ScriptTarget.Latest, /*setParentPointers*/ true);

    // Get the formatting edits on the input sources
    let edits = (&lt;any&gt;ts).formatting.formatDocument(sourceFile, getRuleProvider(options), options);

    // Apply the edits on the input code
    return applyEdits(text, edits);

    function getRuleProvider(options: ts.FormatCodeOptions) {
        // Share this between multiple formatters using the same options.
        // This represents the bulk of the space the formatter uses.
        let ruleProvider = new (&lt;any&gt;ts).formatting.RulesProvider();
        ruleProvider.ensureUpToDate(options);
        return ruleProvider;
    }

    function applyEdits(text: string, edits: ts.TextChange[]): string {
        // Apply edits in reverse on the existing text
        let result = text;
        for (let i = edits.length - 1; i &gt;= 0; i--) {
            let change = edits[i];
            let head = result.slice(0, change.span.start);
            let tail = result.slice(change.span.start + change.span.length)
            result = head + change.newText + tail;
        }
        return result;
    }

    function getDefaultOptions(): ts.FormatCodeOptions {
        return {
            IndentSize: 4,
            IndentStyle: 1,
            TabSize: 4,
            NewLineCharacter: '\n',
            ConvertTabsToSpaces: false,
            InsertSpaceAfterCommaDelimiter: true,
            InsertSpaceAfterSemicolonInForStatements: true,
            InsertSpaceBeforeAndAfterBinaryOperators: true,
            InsertSpaceAfterKeywordsInControlFlowStatements: true,
            InsertSpaceAfterFunctionKeywordForAnonymousFunctions: false,
            InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false,
            InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false,
            InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false,
            PlaceOpenBraceOnNewLineForFunctions: false,
            PlaceOpenBraceOnNewLineForControlBlocks: false,
        };
    }
}


let code = &quot;var a=function(v:number){\n    return 0+1+2+3;\n}&quot;;
let result = format(code);
console.log(result);
"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-s1">ts</span> <span class="pl-k">from</span> <span class="pl-s">"typescript"</span><span class="pl-kos">;</span>

<span class="pl-c">// Note: this uses ts.formatting which is part of the typescript 1.4 package but is not currently </span>
<span class="pl-c">//       exposed in the public typescript.d.ts. The typings should be exposed in the next release. </span>
<span class="pl-k">function</span> <span class="pl-en">format</span><span class="pl-kos">(</span><span class="pl-s1">text</span>: <span class="pl-smi">string</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">let</span> <span class="pl-s1">options</span> <span class="pl-c1">=</span> <span class="pl-en">getDefaultOptions</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-c">// Parse the source text</span>
    <span class="pl-k">let</span> <span class="pl-s1">sourceFile</span> <span class="pl-c1">=</span> <span class="pl-s1">ts</span><span class="pl-kos">.</span><span class="pl-en">createSourceFile</span><span class="pl-kos">(</span><span class="pl-s">"file.ts"</span><span class="pl-kos">,</span> <span class="pl-s1">text</span><span class="pl-kos">,</span> <span class="pl-s1">ts</span><span class="pl-kos">.</span><span class="pl-c1">ScriptTarget</span><span class="pl-kos">.</span><span class="pl-c1">Latest</span><span class="pl-kos">,</span> <span class="pl-c">/*setParentPointers*/</span> <span class="pl-c1">true</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-c">// Get the formatting edits on the input sources</span>
    <span class="pl-k">let</span> <span class="pl-s1">edits</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-kos">&lt;</span><span class="pl-smi">any</span><span class="pl-kos">&gt;</span><span class="pl-s1">ts</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-c1">formatting</span><span class="pl-kos">.</span><span class="pl-en">formatDocument</span><span class="pl-kos">(</span><span class="pl-s1">sourceFile</span><span class="pl-kos">,</span> <span class="pl-en">getRuleProvider</span><span class="pl-kos">(</span><span class="pl-s1">options</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-s1">options</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-c">// Apply the edits on the input code</span>
    <span class="pl-k">return</span> <span class="pl-en">applyEdits</span><span class="pl-kos">(</span><span class="pl-s1">text</span><span class="pl-kos">,</span> <span class="pl-s1">edits</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">function</span> <span class="pl-en">getRuleProvider</span><span class="pl-kos">(</span><span class="pl-s1">options</span>: <span class="pl-s1">ts</span><span class="pl-kos">.</span><span class="pl-smi">FormatCodeOptions</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-c">// Share this between multiple formatters using the same options.</span>
        <span class="pl-c">// This represents the bulk of the space the formatter uses.</span>
        <span class="pl-k">let</span> <span class="pl-s1">ruleProvider</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-kos">(</span><span class="pl-kos">&lt;</span><span class="pl-smi">any</span><span class="pl-kos">&gt;</span><span class="pl-s1">ts</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-c1">formatting</span><span class="pl-kos">.</span><span class="pl-c1">RulesProvider</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-s1">ruleProvider</span><span class="pl-kos">.</span><span class="pl-en">ensureUpToDate</span><span class="pl-kos">(</span><span class="pl-s1">options</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-k">return</span> <span class="pl-s1">ruleProvider</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>

    <span class="pl-k">function</span> <span class="pl-en">applyEdits</span><span class="pl-kos">(</span><span class="pl-s1">text</span>: <span class="pl-smi">string</span><span class="pl-kos">,</span> <span class="pl-s1">edits</span>: <span class="pl-s1">ts</span><span class="pl-kos">.</span><span class="pl-smi">TextChange</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span>: <span class="pl-smi">string</span> <span class="pl-kos">{</span>
        <span class="pl-c">// Apply edits in reverse on the existing text</span>
        <span class="pl-k">let</span> <span class="pl-s1">result</span> <span class="pl-c1">=</span> <span class="pl-s1">text</span><span class="pl-kos">;</span>
        <span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-k">let</span> <span class="pl-s1">i</span> <span class="pl-c1">=</span> <span class="pl-s1">edits</span><span class="pl-kos">.</span><span class="pl-c1">length</span> <span class="pl-c1">-</span> <span class="pl-c1">1</span><span class="pl-kos">;</span> <span class="pl-s1">i</span> <span class="pl-c1">&gt;=</span> <span class="pl-c1">0</span><span class="pl-kos">;</span> <span class="pl-s1">i</span><span class="pl-c1">--</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
            <span class="pl-k">let</span> <span class="pl-s1">change</span> <span class="pl-c1">=</span> <span class="pl-s1">edits</span><span class="pl-kos">[</span><span class="pl-s1">i</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
            <span class="pl-k">let</span> <span class="pl-s1">head</span> <span class="pl-c1">=</span> <span class="pl-s1">result</span><span class="pl-kos">.</span><span class="pl-en">slice</span><span class="pl-kos">(</span><span class="pl-c1">0</span><span class="pl-kos">,</span> <span class="pl-s1">change</span><span class="pl-kos">.</span><span class="pl-c1">span</span><span class="pl-kos">.</span><span class="pl-c1">start</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
            <span class="pl-k">let</span> <span class="pl-s1">tail</span> <span class="pl-c1">=</span> <span class="pl-s1">result</span><span class="pl-kos">.</span><span class="pl-en">slice</span><span class="pl-kos">(</span><span class="pl-s1">change</span><span class="pl-kos">.</span><span class="pl-c1">span</span><span class="pl-kos">.</span><span class="pl-c1">start</span> <span class="pl-c1">+</span> <span class="pl-s1">change</span><span class="pl-kos">.</span><span class="pl-c1">span</span><span class="pl-kos">.</span><span class="pl-c1">length</span><span class="pl-kos">)</span>
            <span class="pl-s1">result</span> <span class="pl-c1">=</span> <span class="pl-s1">head</span> <span class="pl-c1">+</span> <span class="pl-s1">change</span><span class="pl-kos">.</span><span class="pl-c1">newText</span> <span class="pl-c1">+</span> <span class="pl-s1">tail</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span>
        <span class="pl-k">return</span> <span class="pl-s1">result</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>

    <span class="pl-k">function</span> <span class="pl-en">getDefaultOptions</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-s1">ts</span><span class="pl-kos">.</span><span class="pl-smi">FormatCodeOptions</span> <span class="pl-kos">{</span>
        <span class="pl-k">return</span> <span class="pl-kos">{</span>
            <span class="pl-c1">IndentSize</span>: <span class="pl-c1">4</span><span class="pl-kos">,</span>
            <span class="pl-c1">IndentStyle</span>: <span class="pl-c1">1</span><span class="pl-kos">,</span>
            <span class="pl-c1">TabSize</span>: <span class="pl-c1">4</span><span class="pl-kos">,</span>
            <span class="pl-c1">NewLineCharacter</span>: <span class="pl-s">'\n'</span><span class="pl-kos">,</span>
            <span class="pl-c1">ConvertTabsToSpaces</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
            <span class="pl-c1">InsertSpaceAfterCommaDelimiter</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
            <span class="pl-c1">InsertSpaceAfterSemicolonInForStatements</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
            <span class="pl-c1">InsertSpaceBeforeAndAfterBinaryOperators</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
            <span class="pl-c1">InsertSpaceAfterKeywordsInControlFlowStatements</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
            <span class="pl-c1">InsertSpaceAfterFunctionKeywordForAnonymousFunctions</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
            <span class="pl-c1">InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
            <span class="pl-c1">InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
            <span class="pl-c1">InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
            <span class="pl-c1">PlaceOpenBraceOnNewLineForFunctions</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
            <span class="pl-c1">PlaceOpenBraceOnNewLineForControlBlocks</span>: <span class="pl-c1">false</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">let</span> <span class="pl-s1">code</span> <span class="pl-c1">=</span> <span class="pl-s">"var a=function(v:number){\n    return 0+1+2+3;\n}"</span><span class="pl-kos">;</span>
<span class="pl-k">let</span> <span class="pl-s1">result</span> <span class="pl-c1">=</span> <span class="pl-en">format</span><span class="pl-kos">(</span><span class="pl-s1">code</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">result</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Expected behavior:</strong><br>
The <code class="notranslate">return</code> line should be indented with tab.</p>
<p dir="auto"><strong>Actual behavior:</strong><br>
It's actually left untouched because at input it is already indented with 4 spaces and IndentSize is set to 4. This is, however, counter-intuitive, the formatter should fix the indentation to tabs, in my opinion.</p>
<p dir="auto">The reason this happens is in <a href="https://github.com/Microsoft/TypeScript/blob/d960200dac73d077a66b8ac6ef0648895dc3493e/src/services/formatting/formatting.ts#L869">https://github.com/Microsoft/TypeScript/blob/d960200dac73d077a66b8ac6ef0648895dc3493e/src/services/formatting/formatting.ts#L869</a><br>
where the token start position (4) is compared to expected indent size, but there is no check whether the indentation is made from spaces.</p>
<p dir="auto">We have a typescript application and a use a file per class. There are lots of benefits to this the major one being source control conflict reduction.</p>
<p dir="auto">We compile our app using the --out compiler flag but I think there is room for some serious optimization of the compilers output for modules.</p>
<p dir="auto">Currently if you have two classes defined in separate files the compile generates the following JavaScript.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var Example;
(function (Example) {
    (function (Nested) {
        (function (Issue) {
            var bar = (function () {
                function bar() {
                }
                return bar;
            })();
            Issue.bar = bar;
        })(Nested.Issue || (Nested.Issue = {}));
        var Issue = Nested.Issue;
    })(Example.Nested || (Example.Nested = {}));
    var Nested = Example.Nested;
})(Example || (Example = {}));

var Example;
(function (Example) {
    (function (Nested) {
        (function (Issue) {
            var foo = (function () {
                function foo() {
                }
                return foo;
            })();
            Issue.foo = foo;
        })(Nested.Issue || (Nested.Issue = {}));
        var Issue = Nested.Issue;
    })(Example.Nested || (Example.Nested = {}));
    var Nested = Example.Nested;
})(Example || (Example = {}));"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-v">Example</span><span class="pl-kos">;</span>
<span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-v">Example</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-v">Nested</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-v">Issue</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
            <span class="pl-k">var</span> <span class="pl-s1">bar</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
                <span class="pl-k">function</span> <span class="pl-s1">bar</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">bar</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-kos">;</span>
            <span class="pl-v">Issue</span><span class="pl-kos">.</span><span class="pl-c1">bar</span> <span class="pl-c1">=</span> <span class="pl-s1">bar</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">(</span><span class="pl-v">Nested</span><span class="pl-kos">.</span><span class="pl-c1">Issue</span> <span class="pl-c1">||</span> <span class="pl-kos">(</span><span class="pl-v">Nested</span><span class="pl-kos">.</span><span class="pl-c1">Issue</span> <span class="pl-c1">=</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">var</span> <span class="pl-v">Issue</span> <span class="pl-c1">=</span> <span class="pl-v">Nested</span><span class="pl-kos">.</span><span class="pl-c1">Issue</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">(</span><span class="pl-v">Example</span><span class="pl-kos">.</span><span class="pl-c1">Nested</span> <span class="pl-c1">||</span> <span class="pl-kos">(</span><span class="pl-v">Example</span><span class="pl-kos">.</span><span class="pl-c1">Nested</span> <span class="pl-c1">=</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">var</span> <span class="pl-v">Nested</span> <span class="pl-c1">=</span> <span class="pl-v">Example</span><span class="pl-kos">.</span><span class="pl-c1">Nested</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">(</span><span class="pl-v">Example</span> <span class="pl-c1">||</span> <span class="pl-kos">(</span><span class="pl-v">Example</span> <span class="pl-c1">=</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">var</span> <span class="pl-v">Example</span><span class="pl-kos">;</span>
<span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-v">Example</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-v">Nested</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-v">Issue</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
            <span class="pl-k">var</span> <span class="pl-s1">foo</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
                <span class="pl-k">function</span> <span class="pl-s1">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-k">return</span> <span class="pl-s1">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-kos">)</span><span class="pl-kos">;</span>
            <span class="pl-v">Issue</span><span class="pl-kos">.</span><span class="pl-c1">foo</span> <span class="pl-c1">=</span> <span class="pl-s1">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-v">Nested</span><span class="pl-kos">.</span><span class="pl-c1">Issue</span> <span class="pl-c1">||</span> <span class="pl-kos">(</span><span class="pl-v">Nested</span><span class="pl-kos">.</span><span class="pl-c1">Issue</span> <span class="pl-c1">=</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">var</span> <span class="pl-v">Issue</span> <span class="pl-c1">=</span> <span class="pl-v">Nested</span><span class="pl-kos">.</span><span class="pl-c1">Issue</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">(</span><span class="pl-v">Example</span><span class="pl-kos">.</span><span class="pl-c1">Nested</span> <span class="pl-c1">||</span> <span class="pl-kos">(</span><span class="pl-v">Example</span><span class="pl-kos">.</span><span class="pl-c1">Nested</span> <span class="pl-c1">=</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">var</span> <span class="pl-v">Nested</span> <span class="pl-c1">=</span> <span class="pl-v">Example</span><span class="pl-kos">.</span><span class="pl-c1">Nested</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">(</span><span class="pl-v">Example</span> <span class="pl-c1">||</span> <span class="pl-kos">(</span><span class="pl-v">Example</span> <span class="pl-c1">=</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>
<p dir="auto">I suggest a compiler flag that composes all classes/ functions etc under a single module declaration? So the output code would be like the example below. This would dramatically reduce the size of the JavaScript the compiler outputs. I estimate that our app which currently compiles to around 15,000 lines of probably be only be 2000 lines if this were available.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var Example;
(function (Example) {
    (function (Nested) {
        (function (Issue) {
            var bar = (function () {
                function bar() {
                }
                return bar;
            })();
            Issue.bar = bar;
            var foo = (function () {
                function foo() {
                }
                return foo;
            })();
            Issue.foo = foo;
        })(Nested.Issue || (Nested.Issue = {}));
        var Issue = Nested.Issue;
    })(Example.Nested || (Example.Nested = {}));
    var Nested = Example.Nested;
})(Example || (Example = {}));"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-v">Example</span><span class="pl-kos">;</span>
<span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-v">Example</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-v">Nested</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-v">Issue</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
            <span class="pl-k">var</span> <span class="pl-s1">bar</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
                <span class="pl-k">function</span> <span class="pl-s1">bar</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">bar</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-kos">;</span>
            <span class="pl-v">Issue</span><span class="pl-kos">.</span><span class="pl-c1">bar</span> <span class="pl-c1">=</span> <span class="pl-s1">bar</span><span class="pl-kos">;</span>
            <span class="pl-k">var</span> <span class="pl-s1">foo</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
                <span class="pl-k">function</span> <span class="pl-s1">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-k">return</span> <span class="pl-s1">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-kos">)</span><span class="pl-kos">;</span>
            <span class="pl-v">Issue</span><span class="pl-kos">.</span><span class="pl-c1">foo</span> <span class="pl-c1">=</span> <span class="pl-s1">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-v">Nested</span><span class="pl-kos">.</span><span class="pl-c1">Issue</span> <span class="pl-c1">||</span> <span class="pl-kos">(</span><span class="pl-v">Nested</span><span class="pl-kos">.</span><span class="pl-c1">Issue</span> <span class="pl-c1">=</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">var</span> <span class="pl-v">Issue</span> <span class="pl-c1">=</span> <span class="pl-v">Nested</span><span class="pl-kos">.</span><span class="pl-c1">Issue</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">(</span><span class="pl-v">Example</span><span class="pl-kos">.</span><span class="pl-c1">Nested</span> <span class="pl-c1">||</span> <span class="pl-kos">(</span><span class="pl-v">Example</span><span class="pl-kos">.</span><span class="pl-c1">Nested</span> <span class="pl-c1">=</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">var</span> <span class="pl-v">Nested</span> <span class="pl-c1">=</span> <span class="pl-v">Example</span><span class="pl-kos">.</span><span class="pl-c1">Nested</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">(</span><span class="pl-v">Example</span> <span class="pl-c1">||</span> <span class="pl-kos">(</span><span class="pl-v">Example</span> <span class="pl-c1">=</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>