搜索词
支持链接
有用的链接
诊断
建议
VSCode现在可以接受 string
s 或 number
s 作为 Diagnostic
的 code
属性,这使得轻松打开一个显示更多关于错误的详细信息的网站变得舒适:
https://github.com/microsoft/vscode-languageserver-node/blob/9466bf38aef41849b3d48a882e399a34e3127eb2/types/src/main.ts#L581-L624
如果TypeScript语言服务也有相同的选项,不仅可以传递 number
作为错误代码,还可以传递 string
s,最重要的是,包含有用信息的链接,那就太棒了。
用例
基本上,每当你使用一个报告错误的 plugin
时,尤其是当它们有点复杂以至于无法用几句话来描述时。
示例
interceptor.AddMethod(
"getSemanticDiagnostics",
(target, delegate, fileName) =>
{
let diagnostics = delegate(fileName);
diagnostics.push(
{
file: this.Program.getSourceFile(fileName),
start: 1,
length: 1,
messageText: "The member-ordering is incorrect.",
category: ts.DiagnosticCategory.Warning,
source: "eslint",
code: {
value: "import/order",
target: "https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md"
}
}
return diagnostics;
});
检查清单
我的建议满足以下准则:
- 这不会对现有的TypeScript/JavaScript代码造成破坏性的更改
- 这不会改变现有JavaScript代码的运行时行为
- 这可以在不根据表达式的类型发出不同的JS的情况下实现
- 这不是一个运行时特性(例如库功能、JavaScript输出的非ECMAScript语法等)
- 这个特性将与 TypeScript's Design Goals 的其他部分保持一致。
1条答案
按热度按时间wswtfjt71#
@RyanCavanaugh ,我需要提供什么信息才能开始处理这个问题?