functions.js(2,20): error TS1005: '}' expected.
functions.js(3,21): error TS1005: '}' expected.
functions.js(9,23): error TS7006: Parameter 'n' implicitly has an 'any' type.
functions.js(9,35): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
functions.js(12,20): error TS1005: '}' expected.
functions.js(13,21): error TS1005: '}' expected.
functions.js(27,13): error TS2351: This expression is not constructable.
  Type 'Function' has no construct signatures.
functions.js(30,21): error TS1005: '}' expected.
functions.js(31,19): error TS7006: Parameter 'ab' implicitly has an 'any' type.
functions.js(31,23): error TS7006: Parameter 'onetwo' implicitly has an 'any' type.
functions.js(39,3): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
functions.js(43,14): error TS2351: This expression is not constructable.
  Type 'Function' has no construct signatures.
functions.js(48,20): error TS1005: '}' expected.
functions.js(49,13): error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'?
functions.js(51,45): error TS2351: This expression is not constructable.
  Type 'Function' has no construct signatures.
functions.js(61,3): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.


==== functions.js (16 errors) ====
    /**
     * @param {function(this: string, number): number} c is just passing on through
                       ~
!!! error TS1005: '}' expected.
     * @return {function(this: string, number): number}
                        ~
!!! error TS1005: '}' expected.
     */
    function id1(c) {
        return c
    }
    
    var x = id1(function (n) { return this.length + n });
                          ~
!!! error TS7006: Parameter 'n' implicitly has an 'any' type.
                                      ~~~~
!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
    
    /**
     * @param {function(new: { length: number }, number): number} c is just passing on through
                       ~
!!! error TS1005: '}' expected.
     * @return {function(new: { length: number }, number): number}
                        ~
!!! error TS1005: '}' expected.
     */
    function id2(c) {
        return c
    }
    
    class C {
        /** @param {number} n */
        constructor(n) {
            this.length = n;
        }
    }
    
    var y = id2(C);
    var z = new y(12);
                ~
!!! error TS2351: This expression is not constructable.
!!! error TS2351:   Type 'Function' has no construct signatures.
    z.length;
    
    /** @type {function ("a" | "b", 1 | 2): 3 | 4} */
                        ~
!!! error TS1005: '}' expected.
    var f = function (ab, onetwo) { return ab === "a" ? 3 : 4;  }
                      ~~
!!! error TS7006: Parameter 'ab' implicitly has an 'any' type.
                          ~~~~~~
!!! error TS7006: Parameter 'onetwo' implicitly has an 'any' type.
    
    
    /** 
     * @constructor
     * @param {number} n
     */
    function D(n) {
      this.length = n;
      ~~~~
!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
    }
    
    var y2 = id2(D);
    var z2 = new y2(33);
                 ~~
!!! error TS2351: This expression is not constructable.
!!! error TS2351:   Type 'Function' has no construct signatures.
    z2.length;
    
    
    /** 
     * @param {function(new: D, number)} dref
                       ~
!!! error TS1005: '}' expected.
     * @return {D}
                ~
!!! error TS2749: 'D' refers to a value, but is being used as a type here. Did you mean 'typeof D'?
     */
    var construct = function(dref) { return new dref(33); }
                                                ~~~~
!!! error TS2351: This expression is not constructable.
!!! error TS2351:   Type 'Function' has no construct signatures.
    var z3 = construct(D);
    z3.length;
    
    
    /** 
     * @constructor
     * @param {number} n
     */
    var E = function(n) {
      this.not_length_on_purpose = n;
      ~~~~
!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
    };
    
    
    var y3 = id2(E);
    
    // Repro from #39229
    
    /**
     * @type {(...args: [string, string] | [number, string, string]) => void}
     */
    function foo(...args) {
      args;
    }
    
    foo('abc', 'def');
    foo(42, 'abc', 'def');
    