LoginSignup
0
0

More than 1 year has passed since last update.

TypeScriptを極めよう (1)

Posted at

TypeScriptを極めよう (1) - 環境構築

環境構築

作業用のディレクトリを用意、移動。

mkdir typescript-sandbox
src typescript-sandbox

typescript-sandboxでpackage.jsonを生成。--yesを指定すると、全てのオプションがデフォルト値で設定される。

npm -init --yes

TypeScriptを使うのに必須のパッケージをインストール

npm install --save-dev typescript @types/node

tsconfig.json(TypeScriptをJavaScriptにコンパイルする際のオプションを指定するファイル)を生成

npx tsc --init

tsconfig.jsonのCompile

{
  "compilerOptions": {
    "target": "es2020", /* JavaScriptの仕様 */
    "module": "ESNext", /* ES Modulesを解釈できるようにする" */
    "moduleResolution": "node",/* npmでインストールしたモジュールをTypeScriptに認識してもらう */
    "outDir": "./dist", /* コンパイルされた**.jsファイルたちの行き先を指定 */
    "skipLibCheck": true, /* 全ての.d.tsファイルたちの型チェックをスキップ */
  },
  "include": ["./src/**/*.ts"]/* srcディレクトリ以下のファイル全てをコンパイルする対象に指定 */
}

次回

TypeScriptを極めよう (1) - .tsファイルを.jsにコンパイルしてみよう

0
0
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
0
0