<p dir="auto">(Apologies if this is known, but I search a bunch of places and didn't find anything.)</p>
<p dir="auto">Is there a good way to deal with a constructor of a derived class that is getting an options kind of value that needs to be merged with a defaults value?  I started with something like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="export class Foo extends Bar {
    ...
    private options: any = {};
    ...
    constructor(x: Something, y: SomethingElse, options: any = {}) {
        this.options = $.extend({}, defaults, options);
        super(this.options.blah);
        ...
    }
}"><pre class="notranslate"><code class="notranslate">export class Foo extends Bar {
    ...
    private options: any = {};
    ...
    constructor(x: Something, y: SomethingElse, options: any = {}) {
        this.options = $.extend({}, defaults, options);
        super(this.options.blah);
        ...
    }
}
</code></pre></div>
<p dir="auto">This failed and I eventually resorted to:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    constructor(x: Something, y: SomethingElse, options: any = {}) {
        super(options.blah || defaults.blah);
        this.options = $.extend({}, defaults, options);
        ...
    }"><pre class="notranslate"><code class="notranslate">    constructor(x: Something, y: SomethingElse, options: any = {}) {
        super(options.blah || defaults.blah);
        this.options = $.extend({}, defaults, options);
        ...
    }
</code></pre></div>
<p dir="auto">which is duplicating functionality (and sloppy).</p>
<p dir="auto">Hopefully I'm not the only one who ran into this problem and there's good way to do that?</p>
<p dir="auto">In ECMAScript 6, function declarations are lexically scoped.<br>
TypeScript currently reports an error in such case:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="   {
        function f1() { }

        {
            function f1() { }
            f1();  
        }

        f1();
    }"><pre class="notranslate"><code class="notranslate">   {
        function f1() { }

        {
            function f1() { }
            f1();  
        }

        f1();
    }
</code></pre></div>
<p dir="auto">The question is, will it be somehow handled in TypeScript, or will it be left as is?<br>
Sorry if the same issue already exists, I didn't find anything similar.</p>