mytest.js(6,44): error TS2322: Type 'string' is not assignable to type 'T'.
  'T' could be instantiated with an arbitrary type which could be unrelated to 'string'.
mytest.js(13,44): error TS2322: Type 'string' is not assignable to type 'T'.
  'T' could be instantiated with an arbitrary type which could be unrelated to 'string'.


==== mytest.js (2 errors) ====
    /**
     * @template T
     * @param {T|undefined} value value or not
     * @returns {T} result value
     */
    const foo1 = value => /** @type {string} */({ ...value });
                                               ~~~~~~~~~~~~~~
!!! error TS2322: Type 'string' is not assignable to type 'T'.
!!! error TS2322:   'T' could be instantiated with an arbitrary type which could be unrelated to 'string'.
    
    /**
     * @template T
     * @param {T|undefined} value value or not
     * @returns {T} result value
     */
    const foo2 = value => /** @type {string} */(/** @type {T} */({ ...value }));
                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'string' is not assignable to type 'T'.
!!! error TS2322:   'T' could be instantiated with an arbitrary type which could be unrelated to 'string'.