mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
26 lines
1.2 KiB
Plaintext
26 lines
1.2 KiB
Plaintext
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'. |