如何在 JSDoc 打字稿中双重转换值?
出现 TS 2352 错误:
类型“X”到类型“Y”的转换可能是一个错误,因为两种类型都没有与另一种类型充分重叠。如果这是故意的,请首先将表达式转换为“未知”。 ... ts(2352)
如何首先将表达式转换为“未知”?我已经在 JSDoc 打字稿中进行了一次转换:
/** @type {Y} */ (variableOfTypeX)
我在任何地方都找不到这方面的文档。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过尝试和失败,我发现这是如何在 JSDoc 打字稿中双重转换值(首先转换为未知,然后转换为 Y):
By trying and failing, I found this is how to double cast a value in JSDoc typescript (first to unknown and then to Y):