「TypeScriptプロジェクトの始め方」の続き。
素のディレクトリからデフォルト設定で始めるとけっこう色々ハマる。とりあえず次がコンパイルできない。
var map:Map<number, string>; map = new Map<number, string>(); map.set(3, "hello"); console.log(map.get(3));
次はnode.jsで直接実行できるのに。
var map; map = new Map(); map.set(3, "hello"); console.log(map.get(3));
ちゃんとメモ取ってなかったが、確か:
- tsconfig.js の lib の es2021 を設定しても、Mapが無いと言われる。
- コマンドラインで --lib es2021 すると、console.log が無いと言われる。
- コマンドラインラインで --lib es2021 -lib dom すると、Array のような基本データ型(のコンストラクタ)が不明になってしまう。
npm install @types/node で症状が消えたようだが、@types/node はグローバルには入っている(npm install @types/node --global してる)。
jestに関しても:
● Validation Error:
Module ts-jest in the transform option was not found.
<rootDir> is: C:\Users\m-hiyama\Work\TsDevEtc
Configuration Documentation:
https://jestjs.io/docs/configurationこれは設定ファイルをコピーしたら出たエラー。package.json と二重に指定すると:
● Multiple configurations found:
* C:/Users/m-hiyama/Work/TsDevEtc/jest.config.js
* `jest` key in C:/Users/m-hiyama/Work/TsDevEtc/package.json
Implicit config resolution does not allow multiple configuration files.
Either remove unused config files or select one explicitly with `--config`.
Configuration Documentation:
https://jestjs.io/docs/configurationもう一度サラからやってみるか。