如何避免“导入路径不能以 .ts 扩展名结尾"?VSCode 中的错误? [英] How can I avoid the "an import path cannot end with .ts extension" error in VSCode?

查看:2452
本文介绍了如何避免“导入路径不能以 .ts 扩展名结尾"?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 file settings.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆