<p dir="auto">(Update by @RyanCavanuagh)</p>
<p dir="auto">Please see <a href="https://github.com/microsoft/TypeScript/issues/2000#issuecomment-400761370" data-hovercard-type="issue" data-hovercard-url="/microsoft/TypeScript/issues/2000/hovercard">this comment</a> before asking for "any updates", "please add this now", etc.. Comments not meaningfully adding to the discussion will be removed to keep the thread length somewhat reasonable.</p>
<hr>
<p dir="auto">(NOTE, this is <em>not</em> a duplicate of Issue <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="52218177" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/1524" data-hovercard-type="issue" data-hovercard-url="/microsoft/TypeScript/issues/1524/hovercard" href="https://github.com/microsoft/TypeScript/issues/1524">#1524</a>. The proposal here is more along the lines of the C++ override specifier, which makes much more sense for typescript)</p>
<p dir="auto">An override keyword would be immensely useful in typescript. It would be an optional keyword on any method that overrides a super class method, and similar to the override specifier in C++ would indicate an intent that "<em>the name+signature of this method should always match the name+signature of a super class method</em>". This catches a whole range of issues in larger code bases that can otherwise be easily missed.</p>
<p dir="auto">Again similar to C++, <em>it is not an error to omit the override keyword from an overridden method</em>. In this case the compiler just acts exactly as it currently does, and skips the extra compile time checks associated with the override keyword. This allows for the more complex untyped javascript scenarios where the derived class override does not exactly match the signature of the base class.</p>
<h2 dir="auto">Example use</h2>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class Animal {
    move(meters:number):void {
    }
}

class Snake extends Animal {
    override move(meters:number):void {
    }
}"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-smi">Animal</span> <span class="pl-kos">{</span>
    <span class="pl-en">move</span><span class="pl-kos">(</span><span class="pl-s1">meters</span>:<span class="pl-smi">number</span><span class="pl-kos">)</span>:<span class="pl-smi"><span class="pl-k">void</span></span> <span class="pl-kos">{</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-k">class</span> <span class="pl-smi">Snake</span> <span class="pl-k">extends</span> <span class="pl-smi">Animal</span> <span class="pl-kos">{</span>
    <span class="pl-k">override</span> <span class="pl-en">move</span><span class="pl-kos">(</span><span class="pl-s1">meters</span>:<span class="pl-smi">number</span><span class="pl-kos">)</span>:<span class="pl-smi"><span class="pl-k">void</span></span> <span class="pl-kos">{</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<h2 dir="auto">Example compile error conditions</h2>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// Add an additional param to move, unaware that the intent was 
// to override a specific signature in the base class
class Snake extends Animal {
    override move(meters:number, height:number):void {
    }
}
// COMPILE ERROR: Snake super does not define move(meters:number,height:number):void

// Rename the function in the base class, unaware that a derived class
// existed that was overriding the same method and hence it needs renaming as well
class Animal {
    megamove(meters:number):void {
    }
}
// COMPILE ERROR: Snake super does not define move(meters:number):void

// Require the function to now return a bool, unaware that a derived class
// existed that was still using void, and hence it needs updating
class Animal {
    move(meters:number):bool {
    }
}
// COMPILE ERROR: Snake super does not define move(meters:number):void"><pre class="notranslate"><span class="pl-c">// Add an additional param to move, unaware that the intent was </span>
<span class="pl-c">// to override a specific signature in the base class</span>
<span class="pl-k">class</span> <span class="pl-smi">Snake</span> <span class="pl-k">extends</span> <span class="pl-smi">Animal</span> <span class="pl-kos">{</span>
    <span class="pl-k">override</span> <span class="pl-en">move</span><span class="pl-kos">(</span><span class="pl-s1">meters</span>:<span class="pl-smi">number</span><span class="pl-kos">,</span> <span class="pl-s1">height</span>:<span class="pl-smi">number</span><span class="pl-kos">)</span>:<span class="pl-smi"><span class="pl-k">void</span></span> <span class="pl-kos">{</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>
<span class="pl-c">// COMPILE ERROR: Snake super does not define move(meters:number,height:number):void</span>

<span class="pl-c">// Rename the function in the base class, unaware that a derived class</span>
<span class="pl-c">// existed that was overriding the same method and hence it needs renaming as well</span>
<span class="pl-k">class</span> <span class="pl-smi">Animal</span> <span class="pl-kos">{</span>
    <span class="pl-en">megamove</span><span class="pl-kos">(</span><span class="pl-s1">meters</span>:<span class="pl-smi">number</span><span class="pl-kos">)</span>:<span class="pl-smi"><span class="pl-k">void</span></span> <span class="pl-kos">{</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>
<span class="pl-c">// COMPILE ERROR: Snake super does not define move(meters:number):void</span>

<span class="pl-c">// Require the function to now return a bool, unaware that a derived class</span>
<span class="pl-c">// existed that was still using void, and hence it needs updating</span>
<span class="pl-k">class</span> <span class="pl-smi">Animal</span> <span class="pl-kos">{</span>
    <span class="pl-en">move</span><span class="pl-kos">(</span><span class="pl-s1">meters</span>:<span class="pl-smi">number</span><span class="pl-kos">)</span>:<span class="pl-smi">bool</span> <span class="pl-kos">{</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>
<span class="pl-c">// COMPILE ERROR: Snake super does not define move(meters:number):void</span></pre></div>
<h2 dir="auto">IntelliSense</h2>
<p dir="auto">As well as additional compile time validation, the override keyword provides a mechanism for typescript intellisense to easily display and select available super methods, where the intent is to specifically override one of them in a derived class. Currently this is very clunky and involves browsing through the super class chain, finding the method you want to override, and then copy pasting it in to the derived class to guarantee the signatures match.</p>
<h3 dir="auto">Proposed IntelliSense mechanism</h3>
<p dir="auto">Within a class declaration:</p>
<ol dir="auto">
<li>type override</li>
<li>An auto complete drop down appears of all super methods for the class</li>
<li>A method is selected in the drop down</li>
<li>The signature for the method is emitted into the class declaration after the override keyword.</li>
</ol>
<p dir="auto">I noticed that recently a lot of new APIs are added to <code class="notranslate">lib.d.ts</code>. Of cause this is a good thing, however my code breaks badly because of such update.</p>
<p dir="auto">Previously I had added a lot of declarations in my code for HTML5 APIs that were missing in <code class="notranslate">lib.d.ts</code> . Now some of them are added to <code class="notranslate">lib.d.ts</code>, and I get quite a few "duplicated identifier" errors. For example, I had added this piece to play with fullscreen:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="interface Document {
//...
  fullscreenEnabled: boolean;
  mozFullScreenEnabled: boolean;
  webkitFullscreenEnabled: boolean;
}"><pre class="notranslate"><span class="pl-s1">interface</span> <span class="pl-v">Document</span> <span class="pl-kos">{</span>
<span class="pl-c">//...</span>
  fullscreenEnabled: <span class="pl-s1">boolean</span><span class="pl-kos">;</span>
  mozFullScreenEnabled: <span class="pl-s1">boolean</span><span class="pl-kos">;</span>
  webkitFullscreenEnabled: <span class="pl-s1">boolean</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Now <code class="notranslate">fullscreenEnabled</code> and <code class="notranslate">webkitFullscreenEnabled</code> are available in <code class="notranslate">lib.d.ts</code>, and my code breaks, and I have to remove them. However, you are still missing <code class="notranslate">mozFullScreenEnabled</code> right? -- well, waiting for the next break.</p>
<p dir="auto">Web platforms are constantly evolving, it is not practical to expect <code class="notranslate">lib.d.ts</code> always up to date, so developers just have to write such compensating declarations from time to time. Can TS avoid such breaks? I have a few ideas:</p>
<ul dir="auto">
<li>Allow duplicated members in multiple interface declarations, as long as they are identical. In the fullscreen API example above, tsc should not fire errors. Optional compiling warnings are acceptable, to assist developers to remove redundant codes at convenient time.</li>
<li>Make <code class="notranslate">lib.d.ts</code> overridable. When tsc find conflictions between <code class="notranslate">lib.d.ts</code> and client codes, it should pickup declarations in client codes. This is because declarations <code class="notranslate">lib.d.ts</code> may contain bugs, developers should be allowed  to workaround them. E.g. <code class="notranslate">MutationObserver</code>'s constructor was missing a parameter for a long time. Again, optional warnings are welcomed.</li>
</ul>
<p dir="auto">What do you think?</p>