简体   繁体   English

为 VsCode 配置 eslint 以支持类型声明文件?

[英]Configuring eslint for VsCode to support type declaration files?

I am using vsCode for my development and due to the odd nature of my environment I have an api that I can't physically access, currently i'm writing up manual .d.ts files that will act as a psuedo sdk to provide intellisense information and hopefully, linting.我正在使用 vsCode 进行我的开发,由于我环境的奇怪性质,我有一个无法物理访问的 api,目前我正在编写手动 .d.ts 文件,这些文件将充当伪 sdk 以提供智能感知信息和希望,linting。 Issue is eslint in vscode doesn't seem to want to read those files when telling me what variables are undefined, i'm also not entirely sure how to set that all up correctly?问题是 vscode 中的 eslint 在告诉我哪些变量未定义时似乎不想读取这些文件,我也不完全确定如何正确设置所有这些文件?

Update: I believe I solved the issue, by putting, //@ts-check at the top of my javascript file, and using the reference path inline xml tslint seems to start working, giving me linting based on my type declaration files.更新:我相信我解决了这个问题,通过将//@ts-check放在我的 javascript 文件的顶部,并使用参考路径内联 xml tslint 似乎开始工作,根据我的类型声明文件给我 linting。 Also using checkJs: true in your tsconfig.json works as well.在 tsconfig.json 中使用checkJs: true也可以。

It sounds like you're simply trying to get VSCode to do interactive type-checking, and give you intellisense, for a Typescript-based project.听起来您只是想让 VSCode 进行交互式类型检查,并为基于 Typescript 的项目提供智能感知。

If that's correct, you shouldn't have to do ANYTHING special.如果那是正确的,您不应该做任何特别的事情。

I installed John Papa's "Angular Essentials" extension, which happens to include Typescript support.我安装了 John Papa 的“Angular Essentials”扩展,它恰好包含 Typescript 支持。 Althought I would recommend this, there are a million other VSCode Typescript extensions freely available;虽然我会推荐这个,但还有一百万个其他的 VSCode Typescript 扩展可以免费使用; most any of them should also do what you need.他们中的大多数人也应该做你需要的。

I would also install the Chrome Debugger extension, if you haven't already done so.如果您还没有安装 Chrome Debugger 扩展程序,我也会安装。

Q: Does that help, or do you have specific questions that I haven't covered, or specific problems/issues with things you've already tried?问:这有帮助吗,或者你有我没有涉及的具体问题,或者你已经尝试过的事情的具体问题/问题?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM