如何避免“导入路径不能以 .ts 扩展名结尾"?VSCode 中的错误? [英] How can I avoid the "an import path cannot end with .ts extension" error in VSCode?
问题描述
我正在使用 Visual Studio Code 编写 Deno 程序.
Deno 中的 import 语句包含 .ts
扩展名,例如
import { Application } from "https://deno.land/x/oak/mod.ts";
在VS-Code中被标记为问题,错误代码ts(2691):
尽管显示了错误,但程序运行良好,但我想避免出现错误消息,因为没有任何问题.
如何解决?
这可以通过安装和配置
并安装它.
安装后,您可以
转到全局设置(Ctrl、),选择扩展";然后是Deno"并点击Deno:Enable"下的复选框.
或者,推荐的方式,在你的项目中添加一个本地设置:
在您的项目文件夹中创建一个名为
.vscode
的文件夹并添加一个文件settings.json
并添加以下几行:<代码>{deno.enable":真,}
在这两种情况下,重新启动 Visual Studio Code 后,错误应该消失了.
I'm using Visual Studio Code to write Deno programs.
The import statement in Deno contains the .ts
extension, e.g.
import { Application } from "https://deno.land/x/oak/mod.ts";
which is marked as a problem in VS-Code, error code ts(2691):
Despite the shown error, the program works fine, but I want to avoid the error message, because there's nothing wrong.
How can this be solved?
This can be solved by installing and configuring the Deno Extensions for VSCode.
Press CtrlShiftX to open the extensions view, then type "deno" and click on the entry name "Deno - Deno support for VSCode":
and install it.
After installation, you can either
go to the global settings (Ctrl,), select "Extensions" and then "Deno" and click on the checkbox under "Deno:Enable".
or, the recommended way, add a local setting in your project:
create a folder named
.vscode
in your project folder and add a filesettings.json
and add the following lines:{ "deno.enable": true, }
In both cases, after restarting Visual Studio Code, the error should be gone.
这篇关于如何避免“导入路径不能以 .ts 扩展名结尾"?VSCode 中的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!