title: Why are rest parameters undefined in TypeScript?
body: <p>I have a React Native app that I'm programming with TypeScript (3.6.3). I have the following code (the actual code is from an API library but this is a minimum reproducable example):</p>
  
  <pre><code>class Base{
      someVal: string[];
      constructor() {
          this.someVal = [];
      }
      someMethod&lt;T extends Base&gt;(this: T, ...someArgs:string[]){
          debugger;
          this.someVal = someArgs;
      }
  }
  
  class Derived extends Base{
  
  }
  
  let myVar = new Derived().someMethod('hello');
  </code></pre>
  
  <p>The code exactly mimics the library code, and behaves the same (erroneous) way. There are no compiler errors or warnings. When I run the code, I expect <code>someArgs</code> to be <code>['hello']</code>, but it is <code>undefined</code>. Also, I've got an <code>arguments</code> array which contains the actual value of <code>['hello']</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/X0gTu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/X0gTu.jpg" alt="enter image description here"></a></p>
  
  <p>At this point the code (which is transpiled by Babel on the fly) is acting like Javascript (hence, the undefined actual variable and the phantom arguments variable). Why isn't it transpiled correctly and how do I fix it? (I'm on Babel core/runtime 7.6.2)</p>
  
  <p>Here's the relevant code from the generated <code>index.bundle</code>:</p>
  
  <pre><code>    var Base = function () {
      function Base() {
        (0, _classCallCheck2.default)(this, Base);
        this.someVal = [];
      }
  
      (0, _createClass2.default)(Base, [{
        key: "someMethod",
        value: function someMethod() {
          debugger;
  
          for (var _len = arguments.length, someArgs = new Array(_len &gt; 1 ? _len - 1 : 0), _key = 1; _key &lt; _len; _key++) {
            someArgs[_key - 1] = arguments[_key];
          }
  
          this.someVal = someArgs;
        }
      }]);
      return Base;
    }();
  
    var Derived = function (_Base) {
      (0, _inherits2.default)(Derived, _Base);
  
      function Derived() {
        (0, _classCallCheck2.default)(this, Derived);
        return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(Derived).apply(this, arguments));
      }
  
      return Derived;
    }(Base);
  
    var myVar = new Derived().someMethod('hello');
  </code></pre>