LoginSignup
14
4

More than 3 years have passed since last update.

denoの標準ライブラリをVS Codeでいい感じに補完するためにやった作業

Last updated at Posted at 2018-12-27

2018.12.29更新
@keroxp さんがとてもよい方法を発見されていたので、こちらに追記します。

1. deno.d.tsを出力する

deno types > ~/.deno/deno.d.ts

2. 下記のtsconfig.jsonを使う

  • .denoのパスは、ホームディレクトリまでの相対パス
{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "deno": ["../../../.deno/deno.d.ts"],
      "http://*": ["../../../.deno/deps/http/*"],
      "https://*": ["../../../.deno/deps/https/*"]
    }
  }
}

旧版

手順

  1. deno用の作業用ディレクトリ(~/workspaceとする)を作る
  2. ~/workspace内にdenoの補完を使いたいプロジェクト用のディレクトリを作成する
  3. ~/workspace内に https://github.com/denoland/deno をCloneする
  4. ~/workspace内に下記のtsconfig.jsonを置く
{
  "compilerOptions": {
    "baseUrl": ".",
    "lib": ["es2015"],
    "paths": {
      "deno": ["deno/js/deno"]
    }
  }
}

あとは、 ~/workspace をVS Codeで開いて、プロジェクト内のtsファイルで

import { Reader, Writer } from 'deno';

するなりなんなりしてください。
↑の作業を勝手に行ってくれるVS Codeのプラグインがあれば欲しいので誰かお願いします🙏


2018.12.29 追記

@jinjor さんによると、下記のtsconfig.jsonでも結構警告が消えるそうです。
同じディレクトリ配下にdenoを置いておきさえすれば、pathsでエイリアス貼らなくてもよいみたいです

{
  "compilerOptions": {
    "lib": ["es6", "es2018", "dom", "esnext.asynciterable"],
    "target": "es6",
    "module": "commonjs"
  }
}
14
4
3

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
14
4