<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class C {    get x() { return 1; }    get x() { return 1; } // error}

class D {    set x(v) {  }    set x(v) {  } // error}

class E {    get x() {        return 1;    }    set x(v) { }}

var x = {    get x() {        return 1;    },

    // error    get x() {        return 1;    }}

var y = {    get x() {        return 1;    },    set x(v) { }}"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-smi">C</span> <span class="pl-kos">{</span>    <span class="pl-k">get</span> <span class="pl-en">x</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-c1">1</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>    <span class="pl-k">get</span> <span class="pl-en">x</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-c1">1</span><span class="pl-kos">;</span> <span class="pl-kos">}</span> <span class="pl-c">// error}</span>

<span class="pl-c1">class</span> <span class="pl-smi">D</span> <span class="pl-kos">{</span>    <span class="pl-k">set</span> <span class="pl-en">x</span><span class="pl-kos">(</span><span class="pl-s1">v</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>  <span class="pl-kos">}</span>    <span class="pl-k">set</span> <span class="pl-en">x</span><span class="pl-kos">(</span><span class="pl-s1">v</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>  <span class="pl-kos">}</span> <span class="pl-c">// error}</span>

<span class="pl-c1">class</span> <span class="pl-smi">E</span> <span class="pl-kos">{</span>    <span class="pl-k">get</span> <span class="pl-en">x</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-c1">1</span><span class="pl-kos">;</span>    <span class="pl-kos">}</span>    <span class="pl-k">set</span> <span class="pl-en">x</span><span class="pl-kos">(</span><span class="pl-s1">v</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-s1">x</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>    <span class="pl-k">get</span> <span class="pl-en">x</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-c1">1</span><span class="pl-kos">;</span>    <span class="pl-kos">}</span><span class="pl-kos">,</span>

    <span class="pl-c">// error    get x() {        return 1;    }}</span>

<span class="pl-c1">var</span> <span class="pl-s1">y</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>    <span class="pl-k">get</span> <span class="pl-en">x</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-c1">1</span><span class="pl-kos">;</span>    <span class="pl-kos">}</span><span class="pl-kos">,</span>    <span class="pl-k">set</span> <span class="pl-en">x</span><span class="pl-kos">(</span><span class="pl-s1">v</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">Expected:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class C {
        get x() { return 1; }
        get x() { return 1; } // error
!!! Getter 'x' already declared.
    }

    class D {
        set x(v) {  }
        set x(v) {  } // error
!!! Setter 'x' already declared.
    }

    class E {
        get x() {
            return 1;
        }
        set x(v) { }
    }

    var x = {
        get x() {
            return 1;
        },

        // error
        get x() {
            return 1;
        }
!!! Getter 'x' already declared.
    }

    var y = {
        get x() {
            return 1;
        },
        set x(v) { }
    }"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-smi">C</span> <span class="pl-kos">{</span>
        <span class="pl-k">get</span> <span class="pl-en">x</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-c1">1</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
        <span class="pl-k">get</span> <span class="pl-en">x</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-c1">1</span><span class="pl-kos">;</span> <span class="pl-kos">}</span> <span class="pl-c">// error</span>
<span class="pl-c1">!</span><span class="pl-c1">!</span><span class="pl-c1">!</span> <span class="pl-c1">Getter</span><span class="pl-kos"></span> <span class="pl-s">'x'</span> <span class="pl-s1">already</span> <span class="pl-c1">declared</span><span class="pl-kos">.</span>
    <span class="pl-kos">}</span>

    <span class="pl-k">class</span> <span class="pl-smi">D</span> <span class="pl-kos">{</span>
        <span class="pl-k">set</span> <span class="pl-en">x</span><span class="pl-kos">(</span><span class="pl-s1">v</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>  <span class="pl-kos">}</span>
        <span class="pl-k">set</span> <span class="pl-en">x</span><span class="pl-kos">(</span><span class="pl-s1">v</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>  <span class="pl-kos">}</span> <span class="pl-c">// error</span>
<span class="pl-c1">!</span><span class="pl-c1">!</span><span class="pl-c1">!</span> <span class="pl-c1">Setter</span><span class="pl-kos"></span> <span class="pl-s">'x'</span> <span class="pl-s1">already</span> <span class="pl-c1">declared</span><span class="pl-kos">.</span>
    <span class="pl-kos">}</span>

    <span class="pl-k">class</span> <span class="pl-smi">E</span> <span class="pl-kos">{</span>
        <span class="pl-k">get</span> <span class="pl-en">x</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-c1">1</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span>
        <span class="pl-k">set</span> <span class="pl-en">x</span><span class="pl-kos">(</span><span class="pl-s1">v</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-s1">x</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
        <span class="pl-k">get</span> <span class="pl-en">x</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-c1">1</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span><span class="pl-kos">,</span>

        <span class="pl-c">// error</span>
        <span class="pl-k">get</span> <span class="pl-en">x</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-c1">1</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">!</span> <span class="pl-smi">Getter</span> <span class="pl-s">'x'</span> <span class="pl-s1">already</span> <span class="pl-s1">declared</span><span class="pl-kos">.</span>
    <span class="pl-kos">}</span>

    <span class="pl-k">var</span> <span class="pl-c1">y</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
        <span class="pl-k">get</span> <span class="pl-en">x</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-c1">1</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span><span class="pl-kos">,</span>
        <span class="pl-k">set</span> <span class="pl-en">x</span><span class="pl-kos">(</span><span class="pl-s1">v</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">Actual:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    class C {
        get x() { return 1; }
        get x() { return 1; } // error
!!! Duplicate identifier 'x'.
    }

    class D {
        set x(v) {  }
        set x(v) {  } // error
!!! Duplicate identifier 'x'.
    }

    class E {
        get x() {
            return 1;
        }
        set x(v) { }
    }

    var x = {
        get x() {
            return 1;
        },

        // error
        get x() {
!!! Duplicate identifier 'x'.
            return 1;
        }
    }

    var y = {
        get x() {
            return 1;
        },
        set x(v) { }
    }"><pre class="notranslate">    <span class="pl-k">class</span> <span class="pl-smi">C</span> <span class="pl-kos">{</span>
        <span class="pl-k">get</span> <span class="pl-en">x</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-c1">1</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
        <span class="pl-k">get</span> <span class="pl-en">x</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-c1">1</span><span class="pl-kos">;</span> <span class="pl-kos">}</span> <span class="pl-c">// error</span>
<span class="pl-c1">!</span><span class="pl-c1">!</span><span class="pl-c1">!</span> <span class="pl-c1">Duplicate</span> <span class="pl-s1">identifier</span> <span class="pl-s">'x'</span><span class="pl-kos">.</span>
    <span class="pl-kos">}</span>

    <span class="pl-k">class</span> <span class="pl-smi">D</span> <span class="pl-kos">{</span>
        <span class="pl-k">set</span> <span class="pl-en">x</span><span class="pl-kos">(</span><span class="pl-s1">v</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>  <span class="pl-kos">}</span>
        <span class="pl-k">set</span> <span class="pl-en">x</span><span class="pl-kos">(</span><span class="pl-s1">v</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>  <span class="pl-kos">}</span> <span class="pl-c">// error</span>
<span class="pl-c1">!</span><span class="pl-c1">!</span><span class="pl-c1">!</span> <span class="pl-c1">Duplicate</span> <span class="pl-s1">identifier</span> <span class="pl-s">'x'</span><span class="pl-kos">.</span>
    <span class="pl-kos">}</span>

    <span class="pl-k">class</span> <span class="pl-smi">E</span> <span class="pl-kos">{</span>
        <span class="pl-k">get</span> <span class="pl-en">x</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-c1">1</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span>
        <span class="pl-k">set</span> <span class="pl-en">x</span><span class="pl-kos">(</span><span class="pl-s1">v</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-s1">x</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
        <span class="pl-k">get</span> <span class="pl-en">x</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-c1">1</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span><span class="pl-kos">,</span>

        <span class="pl-c">// error</span>
        <span class="pl-k">get</span> <span class="pl-en">x</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">!</span> <span class="pl-smi">Duplicate</span> <span class="pl-s1">identifier</span> <span class="pl-s">'x'</span><span class="pl-kos">.</span>
            <span class="pl-c1">return</span> <span class="pl-c1">1</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-s1">y</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
        <span class="pl-k">get</span> <span class="pl-en">x</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-c1">1</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span><span class="pl-kos">,</span>
        <span class="pl-k">set</span> <span class="pl-en">x</span><span class="pl-kos">(</span><span class="pl-s1">v</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">From <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="141163009" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/7535" data-hovercard-type="issue" data-hovercard-url="/microsoft/TypeScript/issues/7535/hovercard" href="https://github.com/microsoft/TypeScript/issues/7535">#7535</a>, it would be useful for JavaScript package authors to have the ability to generate declarations from their project. This would help with getting started on a type definition (it would be populated with known interfaces/functions/types that are exported) and would also allow the creation of continuous integration scripts that check the JavaScript types with the hand-coded definition for inconsistencies.</p>