[SOLVED] How to double cast a value in JSDoc typescript?


Getting the TS 2352 error:

Conversion of type 'X' to type 'Y' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. ... ts(2352)

How do I convert the expression to ‘unknown’ first? I am already doing a single cast in JSDoc typescript:

/** @type {Y} */ (variableOfTypeX)

I can’t find the documentation for this anywhere.


By trying and failing, I found that is how to double cast a value in JSDoc typescript (first to unknown and then to Y):

/** @type {Y} */ (/** @type {unknown} */ (variableOfTypeX))

Answered By – Magne

Answer Checked By – Mary Flores (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *