TypeScript [tsserverlibrary] 允许报告有用的链接和错误名称

u3r8eeie  于 8个月前  发布在  TypeScript
关注(0)|答案(1)|浏览(95)

搜索词

支持链接
有用的链接
诊断

建议

VSCode现在可以接受 string s 或 number s 作为 Diagnosticcode 属性,这使得轻松打开一个显示更多关于错误的详细信息的网站变得舒适:
https://github.com/microsoft/vscode-languageserver-node/blob/9466bf38aef41849b3d48a882e399a34e3127eb2/types/src/main.ts#L581-L624
如果TypeScript语言服务也有相同的选项,不仅可以传递 number 作为错误代码,还可以传递 string s,最重要的是,包含有用信息的链接,那就太棒了。

用例

基本上,每当你使用一个报告错误的 plugin 时,尤其是当它们有点复杂以至于无法用几句话来描述时。

示例

  1. interceptor.AddMethod(
  2. "getSemanticDiagnostics",
  3. (target, delegate, fileName) =>
  4. {
  5. let diagnostics = delegate(fileName);
  6. diagnostics.push(
  7. {
  8. file: this.Program.getSourceFile(fileName),
  9. start: 1,
  10. length: 1,
  11. messageText: "The member-ordering is incorrect.",
  12. category: ts.DiagnosticCategory.Warning,
  13. source: "eslint",
  14. code: {
  15. value: "import/order",
  16. target: "https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md"
  17. }
  18. }
  19. return diagnostics;
  20. });

检查清单

我的建议满足以下准则:

  • 这不会对现有的TypeScript/JavaScript代码造成破坏性的更改
  • 这不会改变现有JavaScript代码的运行时行为
  • 这可以在不根据表达式的类型发出不同的JS的情况下实现
  • 这不是一个运行时特性(例如库功能、JavaScript输出的非ECMAScript语法等)
  • 这个特性将与 TypeScript's Design Goals 的其他部分保持一致。
wswtfjt7

wswtfjt71#

@RyanCavanaugh ,我需要提供什么信息才能开始处理这个问题?

相关问题