-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce Typescript for only Tests #13
Changes from 2 commits
4ebf067
b562030
ca03239
ff89614
4e35dcb
14e77dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--compilers ts:ts-node/register,tsx:ts-node/register | ||
|
||
--require source-map-support/register | ||
--require ./test/resolver.js | ||
|
||
--check-leaks | ||
--full-trace | ||
--recursive | ||
--timeout 1000 | ||
|
||
test/**/*.spec.{ts,tsx} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const path = require('path'); | ||
const tsConfigPaths = require('tsconfig-paths'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [eslint]
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [eslint]
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 |
||
|
||
const tsConfig = require('./tsconfig.json'); | ||
|
||
const baseUrl = path.join(__dirname, tsConfig.compilerOptions.baseUrl); | ||
const paths = tsConfig.compilerOptions.paths; | ||
|
||
paths['src/Image'] = [ | ||
'./', | ||
]; | ||
|
||
tsConfigPaths.register({ | ||
baseUrl, | ||
paths, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"baseUrl": "../", | ||
"checkJs": false, | ||
"lib": [ | ||
"es6" | ||
], | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"noEmitOnError": true, | ||
"outDir": "build/", | ||
"paths": { | ||
"*": [ | ||
"*" | ||
] | ||
}, | ||
"removeComments": true, | ||
"sourceMap": true, | ||
"strictNullChecks": true, | ||
"target": "es5", | ||
"jsx": "react" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tsconfig-pathsはなぜ必要なんですか?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ts-node
が最初にコンパイルして出力したファイルを実行する時、パス解決をするために必要だからです。つまり、
ts-node
とbabel-plugin-resolver
相当の機能(compulerOptions
のbaseUrl/paths
を組み合わせて設定する)ために、tsconfig-paths
が必要ということです。TypeStrong/ts-node#138 (comment)