如何在没有"N more"的情况下查看完全展开的TypeScript类型?和"..."? [英] How to see a fully-expanded TypeScript type without "N more" and "..."?

查看:139
本文介绍了如何在没有"N more"的情况下查看完全展开的TypeScript类型?和"..."?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VSCode中,TypeScript显示了我定义的类型的非常有用的扩展.但是TS在IntelliSense中显示的内容是有限制的.如果类型太长,那么我将看到如下输出:

In VSCode, TypeScript shows really useful expansions of types I define. But there's a limit to what TS will show in IntelliSense. If a type is too long, then I'll see output like this:

请注意结尾处的还有11个"字样.有时,要解决疑难的类型定义,查看"N更多"部分中的内容确实很有帮助.

Note the "11 more" near the end. Sometimes, for troubleshooting a difficult type definition, it's really helpful to see what's in that "N more" section.

有没有办法(为了在开发过程中进行故障排除)完全扩展的类型定义,而没有那些"N更多"消息来隐藏内部内容?

Is there a way to get ahold of (for troubleshooting purposes during development) the fully-expanded type definition, without those "N more" messages to hide what's inside?

https://github.com/Microsoft/vscode/issues/6638 暗示到2017年2月该功能可能尚不可用(或计划中),但是我不确定我是否在正确地阅读了该问题,无论与此同时情况是否有所变化.

https://github.com/Microsoft/vscode/issues/6638 implies that this capability might not have been available (nor planned) as of Feb 2017, but I'm not sure I'm reading that issue correctly and regardless things may have changed in the meantime.

推荐答案

尝试在tsconfig.json中将noErrorTruncation选项设置为true.令人困惑的是,此选项至少在某些情况下会影响悬停时显示的类型的截断.请参见此问题.请注意:如果您的类型确实很大,则当您尝试查看它时,VS Code可能会挂起.

Try setting the noErrorTruncation option to true in tsconfig.json. Confusingly enough, this option affects truncation of types displayed on hover in at least some circumstances; see this issue. Be careful: if your type is really huge, VS Code may hang when you try to view it.

这篇关于如何在没有"N more"的情况下查看完全展开的TypeScript类型?和"..."?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆