Introduce Typescript for only Tests#13
Conversation
| "files.trimTrailingWhitespace": true, | ||
| "files.autoSave": "onFocusChange", | ||
| "files.exclude": { | ||
| "**/.git": true, |
There was a problem hiding this comment.
デフォルト設定も書く必要あります?
excludeしたいものだけを書くと、上書きではなく追加されるように見えますが。
| @@ -0,0 +1,16 @@ | |||
| const tsConfigPaths = require('tsconfig-paths'); | |||
There was a problem hiding this comment.
[eslint]
- Error - Unable to resolve path to module 'tsconfig-paths'. (import/no-unresolved)
| @@ -0,0 +1,16 @@ | |||
| const path = require('path'); | |||
| const tsConfigPaths = require('tsconfig-paths'); | |||
There was a problem hiding this comment.
[eslint]
- Error - Unable to resolve path to module 'tsconfig-paths'. (import/no-unresolved)
| "react-dom": "^15.4.1", | ||
| "source-map-support": "^0.4.15", | ||
| "ts-node": "^3.0.4", | ||
| "tsconfig-paths": "^2.1.2", |
There was a problem hiding this comment.
ts-node が最初にコンパイルして出力したファイルを実行する時、パス解決をするために必要だからです。
つまり、ts-node と babel-plugin-resolver相当の機能(compulerOptions の baseUrl/paths を組み合わせて設定する)ために、tsconfig-paths が必要ということです。
tsconfig-paths is not necessary
|
拡張子の件はこのコミットでやりました -> |
| const originalLoader = Module._load; | ||
| const patchedLoader = (request, parent, isMain) => { | ||
| try { | ||
| return originalLoader.call(null, request, parent, isMain); |
There was a problem hiding this comment.
Node.jsの Module.__load にパッチを当てています https://github.com/nodejs/node/blob/master/lib/module.js#L432
これが見つからなかったら .jsx 拡張子を当てて再度ロードするようにしています。本体であればいくつかのケースに備えて作る必要がありそうですが、本質的にはこのような解決策でいけそうです。
There was a problem hiding this comment.
最終的にすべてのファイルが TypeScript 化し、resolveする必要がなくなったらこのファイルをまるっと消せば良さそうです。
|
LGTM |
|
ありがとうございます 🙏 |
|
👀 |
This PR
tsconfig.json)ts-nodeto transpile TypeScript filesbaseOptions/pathscompilerOptions along withts-ndoe