title: Detecting interfaces and duck typing in Closure
body: <p>There are a couple places in the Closure library where interfaces have an <code>addImplementation/isImplementedBy</code> pair of functions to do runtime type checking on the interface (similar to <a href="https://stackoverflow.com/a/28080310/20846">this answer</a>).  I'm not entirely a fan of this solution where I have something very simple.  Is there any way to do duck typing with ADVANCED_OPTIMIZATIONS enabled?  Say I have an interface, and a component that takes special action on children with that interface, e.g.:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>/** @interface */
  MyInterface = function() {};
  
  MyInterface.prototype.doSomething = function() {};
  
  /**
   * @constructor
   * @extends {goog.ui.Component}
   */
  MyComponent = function() {
     ...
  };
  
  /** @inheritDoc */
  MyComponent.prototype.addChild = function(child, opt_render) {
    goog.base(this, 'addChild', child, opt_render);
    if (child.doSomething) {
      child.doSomething();  
    }
  };</code></pre>
  </div>
  </div>
  </p>
  
  <p>Will ADVANCED_OPTIMIZATIONS consistently rename that "doSomething" property with the implementations?  If not, will adding a type union ensure that it will? e.g.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>/**
   * @param {goog.ui.Component|MyInterface} child
   */
  MyComponent.prototype.addChild = function( child, opt_render) {
    if (child.doSomething) {
      child.doSomething();  
    }
  };</code></pre>
  </div>
  </div>
  </p>