[英]How do I configure Visual Studio Code for Typescript?
I'm writing typescript with not much experience and when I deploy my functions to the server, I get a ton of errors like "character limit for each line must be 80 characters", "blocks cannot be padded", "unexpected var, use let or const instead", indentation errors, etc. But there are so many that I feel like maybe I missed a step in configuring Visual Studio Code specifically for Typescript. For example, is there a way I can draw a vertical line in the editor to serve as a visual aid for the 80 character limit?我在写 typescript 时经验不多,当我将函数部署到服务器时,出现大量错误,例如“每行的字符数限制必须为 80 个字符”、“无法填充块”、“意外的 var,使用let or const instead”, 缩进错误等等。但有太多我觉得我可能错过了专门为 Typescript 配置 Visual Studio Code 的步骤。例如,有没有办法在编辑器中画一条垂直线作为 80 个字符限制的视觉辅助工具?
Edit: added some error examples编辑:添加了一些错误示例
26:32 warning 'context' is defined but never used @typescript-eslint/no-unused-vars
45:1 error Missing JSDoc comment require-jsdoc
46:1 error Expected indentation of 4 spaces but found 2 indent
47:1 error Expected indentation of 4 spaces but found 2 indent
48:1 error Expected indentation of 4 spaces but found 2 indent
49:1 error Expected indentation of 0 spaces but found 2 indent
55:3 error Unexpected var, use let or const instead no-var
55:7 error Type number trivially inferred from a number literal, remove type annotation @typescript-eslint/no-inferrable-types
55:28 error Missing semicolon semi
56:3 error Unexpected var, use let or const instead no-var
56:7 error Type string trivially inferred from a string literal, remove type annotation @typescript-eslint/no-inferrable-types
56:34 error Missing semicolon semi
57:3 error Unexpected var, use let or const instead no-var
57:7 error Type string trivially inferred from a string literal, remove type annotation @typescript-eslint/no-inferrable-types
57:29 error Missing semicolon semi
64:1 error This line has a length of 83. Maximum allowed is 80 max-len
64:84 error Missing semicolon semi
66:20 error Missing semicolon semi
67:50 error Missing semicolon semi
68:21 error Missing semicolon semi
70:20 error Missing semicolon semi
71:26 error Missing semicolon semi
72:47 error Missing semicolon semi
73:6 error Trailing spaces not allowed no-trailing-spaces
78:1 error This line has a length of 112. Maximum allowed is 80 max-len
78:113 error Missing semicolon semi
81:24 error Expected parentheses around arrow function argument arrow-parens
82:47 error Missing semicolon semi
85:20 error Missing semicolon semi
86:21 error Missing semicolon semi
88:20 error Missing semicolon semi
89:26 error Missing semicolon semi
90:47 error Missing semicolon semi
91:6 error Trailing spaces not allowed no-trailing-spaces
93:1 error Trailing spaces not allowed no-trailing-spaces
94:48 error Missing semicolon semi
99:32 warning 'context' is defined but never used @typescript-eslint/no-unused-vars
130:18 warning 'response' is defined but never used @typescript-eslint/no-unused-vars
Install the typescript compiler using the command npm install -g typescript
.使用命令npm install -g typescript
typescript 编译器。
For more information you can read on their official documentation https://code.visualstudio.com/docs/languages/typescript有关更多信息,您可以阅读他们的官方文档https://code.visualstudio.com/docs/languages/typescript
Try using prettier and configure vscode to format on save .尝试使用prettier并配置 vscode 以在保存时格式化。 This will take care of line length and indentation errors at least.这将至少处理行长和缩进错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.