LoginSignup
2
1

More than 3 years have passed since last update.

【deno】「An import path cannot end with a '. ts'extension.」のエラーを回避する方法

Last updated at Posted at 2019-10-15

概要

以下の画像のように「An import path cannot end with a '.ts' extension...」というエラーが発生してしまう問題を回避したい。

Screenshot.png

前提

Vim等のエディタを利用する場合を想定しています。
vscodeを利用する場合は、vscode-denoプラグインを導入することで解決すると思います。

環境

  • deno: v0.20.0
  • dem: v0.2.0
dem.json
{
  "version": "0.2.0",
  "modules": [
    {
      "protocol": "https",
      "path": "deno.land/std",
      "version": "v0.20.0",
      "files": [
        "/fs/path.ts"
      ]
    }
  ]
}

下記のようにtsconfig.jsonを用意したが、エラーが発生してしまった。

types/deno.d.ts$ deno typesの実行結果を格納している。

tsconfig.json
{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "baseUrl": ".",
    "paths": {
      "deno": ["./types/deno.d.ts"],
      "https://*": [
        "../../../.cache/deno/deps/https/*"
      ],
      "http://*": [
        "../../../.cache/deno/deps/http/*"
      ]
    }
  }
}

解決策

以下手順で解決した。

$ yarn add --dev deno_ls_plugin typescript
  • 2. tsconfig.jsonを編集し、deno_ls_pluginを読み込むように設定する。
{
   "compilerOptions": {
     ... 省略 ...
    },
    "plugins": [{ "name": "deno_ls_plugin" }]
   }
 }

"plugins": [{ "name": "deno_ls_plugin" }]の行を追記したところ、解決した。

Screenshot.png

追記(2019/10/17)

denopkg.comからモジュールをダウンロードしようとしたところ、同様の事象が発生してしまった。
typescript-deno-pluginを導入することで解決する。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1